@Configuration注解的ben不会自动被扫描进来、加载吗?

买房动力十足 2017-07-29 02:13:37
1、
@Configuration
@EnableCaching
public class RedisCacheCofig extends CachingConfigurerSupport {

}

2、

@Configuration
@ComponentScan(
useDefaultFilters = false,
includeFilters = {
@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Controller.class),
@ComponentScan.Filter(type = FilterType.ANNOTATION, value = ControllerAdvice.class),
@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Service.class),
@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Repository.class),
// @ComponentScan.Filter(type = FilterType.ANNOTATION, value = Configuration.class)加入此配置RedisCacheCofig 才能被加载进来
},
basePackages = {
"com.xxx.cache",
"com.xxx.mall.controller",
"com.xxx.api"
})
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class WebMvcConfig extends WebMvcConfigurerAdapter {


3、WebMvcConfig 包的扫描已经包含RedisCacheCofig 奇怪的是
@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Configuration.class)
加入此配置RedisCacheCofig 才能被加载进来,不加就加载不了,布置为何。



@Configuration注解不就是相当于<bean id="XXX">吗?
...全文
551 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧