Managing the complexity of a dependency-nested application with lots of beans

I am working on a Spring application that has a large number of beans - in hundreds - and it becomes quite cumbersome to use and document.

I’m interested in any experience that you have with DI-enabled applications with lots of beans, which will help in maintainability, documentation, and general use.

Despite the fact that the Spring application is based on several context files, I am open to listening to suggestions regarding any DI container and about DI in general.

+5
source share
4 answers

I found the following:

  • Spring Spring (. , 3.2.2.1). , , , ( ).
  • IDE, Spring -aware, point-n-click beans (/, --- ). Intellij ( 7 , ). , Eclipse - .
  • , . , bean "" bean . , , - , ( , ..).

Spring (?) beans. / .. , Intellij Spring, Intellij, . Spring -aware IDE .

+4

, Spring XML.

:


<beans>
  <!-- Scans service package looking for @Service annotated beans -->
  <context:component-scan base-package="my.root.package.service"/>

</beans>

:


package my.root.package.service;

@Service("fooService") public class FooServiceImpl implements FooService{

}

@Autowired , Spring, bean:


package my.root.package.service;

@Service("barService")
public class BarServiceImpl implements BarService{
    //Foo service injected by Spring
    @Autowired
    private FooService fooService;

    //...
}

+6

@Wilson Freitas, autowiring. , spring beans, autowired. , " " . , . @Autowiring , xml-based spring, - , IDE .

, , "" , spring. . , ; , , spring. spring , JSR-330 , " " .

+3

:

  • , : fooService, fooDao, fooController;
  • ;
  • auto message by name (autowire = "byName"); we had a lot of problems with auto-negotiation by type, especially at the controller level.
+1
source

All Articles