一、说明
1、项目依赖其他子模块
2、子模块中做了一些自动注入的配置,比如@Component,@Configuration,甚至@Service
3、但是呢,想用到子模块的utils,不想用自动注入的服务
二、解决方案
在main方法所在类增加注解
1、排除类
@ComponentScan(basePackages = {"cn.hg", "cn.hutool"},excludeFilters = {@ComponentScan.Filter(
// 排除不需要的@Component,@Configuration
type = FilterType.ASSIGNABLE_TYPE, classes = {JwtAuthenticationTokenFilter.class, FilterConfig.class, TokenService.class})})
2、排除包
@ComponentScan(basePackages = {"cn.hg", "cn.hutool"},excludeFilters = {@ComponentScan.Filter(
// 排除不需要扫描的包
type = FilterType.REGEX, pattern = {
"cn.hg.demo.*"
})})