Even if the compilation passes, an error will occur at runtime, so you must give a unique name. If you attach them one by one by hand, mistakes are likely to occur, so attach them automatically.
FQCNBeanNameGenerator.java
public class FQCNBeanNameGenerator extends AnnotationBeanNameGenerator {
@Override
protected String buildDefaultBeanName(BeanDefinition definition) {
return definition.getBeanClassName();
}
}
Before change: servlet-context.xml
<context:component-scan base-package="jp.co.test" />
After change: servlet-context.xml
<context:component-scan
base-package="jp.co.test"
name-generator="jp.co.test.FQCNBeanNameGenerator" />
https://qiita.com/sinsengumi/items/655d9f3ff49646dfe61a http://d.hatena.ne.jp/ocs/20101129/1291034951
Recommended Posts