11 java spring spring-mvc listener interceptor
我有春季申请(我没有懒豆).
我想在初始化所有@Component(@Repositoey @Service @Controller)bean时插入逻辑.
我该怎么做?
trf*_*trf 16
正如在这个问题的答案中提到的,您可以使用ApplicationListener并查找ContextRefreshedEvent:
public class Loader implements ApplicationListener<ContextRefreshedEvent>{
public void onApplicationEvent(ContextRefreshedEvent event) {
// whatever you want to do when app context is initialized or refreshed
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6074 次 |
| 最近记录: |