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

java, spring

Solution

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.

Problem

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?

Original source