http://stackoverflow.com/questions/24130166/componentscan-basepackageclasses-vs-componentscan-basepackages-to-register-a-sin
The full javadoc for that attribute reads
Type-safe alternative to basePackages() for specifying the packages to scan for annotated components. The package of each class specified will be scanned.
Consider creating a special no-op marker class or interface in each package that serves no purpose other than being referenced by this attribute.
By type-safe, you can't make any mistakes with the String
value of the name of the package. If you specify an incorrect class, it will fail at compile time.
When you specify basePackageClasses
, Spring will scan the package (and subpackages) of the classes you specify. This is a nice trick with no-op classes/interfaces like Controllers
, Services
, etc. Put all your controllers in one package containing the Controllers
class and specify your Controllers
class in the basePackageClasses
. Spring will pick them all up.
You still need to specify the filters.
basePackageClasses 는 컴파일시에 체크가능, 별도의 root 클래스가 있어야함.
basePackages 는 런타임시에 체크가능
'emotional developer > detect-Java' 카테고리의 다른 글
slf4j multiple bindings error (0) | 2015.07.26 |
---|---|
[spring] device detction interceptor - DeviceResolverHandlerInterceptor (0) | 2015.06.18 |
[spring] WebMvcConfigurerAdapter vs WebMvcConfigurationSupport (0) | 2015.06.18 |