做到4.9 增加网关模块gateway的时候,发现gatewayApplication虽然也ComponentScan了,但是却没扫到common里的LogAspect
很不解,在查阅资料后发现:
@ComponentScan添加扫描范围
@SpringBootApplication
@ComponentScan(basePackages = {"com.xx"})
public class UserApplication {
public static void main(String[] args) {
SpringApplication.run(UserApplication.class, args);
}
}
在当前pom.xml引入需扫描包的pom.xml
<dependencies>
<dependency>
<artifactId>xx.xxx.xxx</artifactId>
<groupId>com.xx</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
需扫描的类添加@Configuration