私のxml構成ファイルに書くことができます
<context:component-scan base-package="com.my.stuff"/>
次に、Java ベースの構成に進みます。@Configuration
そこになくても、ベースクラスでそれを行うにはどうすればよいApplicationContext
ですか?
私のxml構成ファイルに書くことができます
<context:component-scan base-package="com.my.stuff"/>
次に、Java ベースの構成に進みます。@Configuration
そこになくても、ベースクラスでそれを行うにはどうすればよいApplicationContext
ですか?
@ComponentScanアノテーションを構成クラスに使用できます。
例 :
@Configuration
@ComponentScan("com.acme.app.services")
public class AppConfig {
@Bean
public MyBean myBean() {
// instantiate, configure and return bean ...
}
}
spring < 3.1 の場合、 @Configuration クラスの @PostConstruct メソッドでhttp://static.springsource.org/spring/docs/2.5.x/api/org/springframework/context/annotation/ClassPathBeanDefinitionScanner.htmlを使用できます。もちろん、ApplicationContext を @Configuration に自動配線する必要があります。