Is Spring @ Tired of a huge performance issue?

I have a project that has ... I don't know ... 200-300 daos / services / controllers, and I use @Autowired to connect everything, and not to specify everything in applicationContext.xml .

My question is: how much does this affect boot performance? Would it be advisable to remove all @Autowired annotations and actually connect this application manually through applicationContext.xml ?

From an architectural point of view, I like @Autowired . I do not want to add another level of complexity using the xml file - it does not add any value as far as I know. But if such a thing adds 10 seconds to my container loading time, I can consider it. If the cost is 100 milliseconds, then I will leave it as it is.

thanks

+6
source share
2 answers

Pretty much the same. Scanning components is a bit more expensive (when scanning @Service , @Component ), but, as you said, this is the launch time - this happens only once. And in a moderate car, it starts pretty quickly even with annotations.

As a rule, I will not give up the approach just because it adds a little startup time. And I can assure you that this is nothing significant (work on a larger project than your right now)

+5
source

There is an interesting comment by @Masterhard in Spring @ Custom usage :

We are moving from @Autowire to the XML configuration in our large project. The problem is the very low boot . The Autowiring scanner loads all classes from the search class into autowiring, so many classes are loaded impatiently during Spring initialization.

Also see, for example, SPR-6870 .

However! Auto-processing using annotations is so convenient that I would have thought twice before switching to XML. If startup time is not a problem in your project, and you can prove that it is a CLASSPATH scan that calls it, it remains with annotations. Also remember that Java EE also moves in annotations.

PS: Parsing thousands of XML lines also leads to some overhead.

+4
source

Source: https://habr.com/ru/post/902253/


All Articles