兄弟们,帮忙看一个 spring 的问题

2021-06-29 17:26:11 +08:00
 liian2019
我有一个壳子项目,里面集成了 4 个 jar 包,但是这四个 jar 包有些 bean 是冲突的,所以使用 @ComponentScan 的 filter 来排除掉一些类。启动类注解如下:
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
@EnableScheduling
@EnableAsync
@EnableAspectJAutoProxy(exposeProxy = true)
@EnableTransactionManagement
@ComponentScan(basePackages = {"com.liian"},excludeFilters =
{@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,classes = {ParamValidateConfiguration.class,
MybatisPlusConfig.class,MPMetaObjectHandler.class})})


现在问题是 ParamValidateConfiguration 和 MybatisPlusConfig 可以被排除掉,而 MPMetaObjectHandler 不可以。经过观察发现,前两个标注了 @Configuration 注解,而后一个标注的是 @Component 注解,实验后面发现只要标注的是 @Component 注解的类都不能被排除掉。

请问下大佬们知道是为什么嘛
869 次点击
所在节点    Java
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/786516

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX