Sta*_*lin 5 java configuration spring
在我的xml配置文件中,我可以写
<context:component-scan base-package="com.my.stuff"/>
Run Code Online (Sandbox Code Playgroud)
现在我继续进行基于java的配置.@Configuration如果没有ApplicationContext那里我怎么能在我的班级里做到这一点?
Nan*_*ale 15
您可以将@ComponentScan批注用于配置类.
示例:
@Configuration
@ComponentScan("com.acme.app.services")
public class AppConfig {
@Bean
public MyBean myBean() {
// instantiate, configure and return bean ...
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3561 次 |
| 最近记录: |