一.错误
Redundant declaration: @SpringBootApplication already applies given @ComponentScan(冗余声明:@SpringBootApplication已应用于给定的@ComponentScan)
二.场景
这是我在给微服务配置feign负载平衡的时候,我要在(feign模块)配置去扫描(api模块)下的包,然后出现下面的bug @ComponentScan的注解报红
三.原因
已知@ComponentScan会默认扫描当前包
我要扫描的另一个模块包下的service的包 (api模块)
我当前模块的包 (feign模块)
因为我的配置是@ComponentScan(“com.xin”),然后当前模块
和我想要扫描的包
都有com.xin,再加上@ComponentScan默认扫描当前包,所以这就会报你的注解是冗余的
四.解决方法
1.把你要扫描的包写的更详细一点
2.把你要导入的包改一个名字
我直接把api模块的包名改了,这样就不和feign模块的包名冲突了,解决。