Is there any performance with Spring if I use component scanning and make the base package my root package?

I am using Spring 3. In my xml application context file, I would like to use the scan component and run com.mysite in my root package and not explicitly add each package:

would like to do

<context:component-scan base-package="com.mysite"/> 

not

 <context:component-scan base-package="com.mysite.util"/> <context:component-scan base-package="com.mysite.transactions"/> <context:component-scan base-package="com.mysite.etc"/> 

Is there any success anyway? Is there any recommended way to Spring 3?

+4
source share
2 answers

Not many (maybe a few milliseconds), because it is one time, and this only happens when the container is launched for the first time. But it is always recommended to narrow the scanning path.

+3
source

It is not possible to achieve performance; components are scanned at boot time and not at runtime.

But I have some memories that this does not work, because component scanning is not recursive (for packages), so you need to specify each package that you want to find. Correct me otherwise.

+1
source

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


All Articles