开发者

Is there a performance hit with Spring if I use component-scan and make the base-package my root package?

I am using Spring 3. In my application context xml file I would like to use component-scan and start in my root package com.mysite and not explicitly add every 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 a performance hit for either way? Is there a 开发者_如何学Crecommended spring 3 way to do this?


Not much (May be a few milli sec) as it is one time thing and it does only when the container starts up for the first time. But it is always recommended to narrow down the scan path.


There can't be a performance hit, component scan happens at load time, not runtime.

But I have some memories that it doesn't work because component scan is not recursive (for packages) so you have to specify each package you want to be searched. Correct me otherwise.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜