tags:

views:

268

answers:

2

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 recommended spring 3 way to do this?

+1  A: 

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.

Teja Kantamneni
A: 

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.

sibidiba
component scan does seem to be recursive in Spring 3
SWD