springboot项目中扫描其他模块的包中类
结构图:

步骤:
1、在需要扫描的类中添加注解@Configuration,例如:

2、在service模块pom.xml中配置service_base依赖,artifactId中是模块名
<dependency> <groupId>com.feng</groupId> <artifactId>service_base</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency>
3、在EduApplication类中配置扫描路径

结果(我是用swagger时使用的),成功打开service_base模块下的文件:


本文来自博客园,作者:金玉良猿,转载请注明原文链接:https://www.cnblogs.com/LLFA/p/14428701.html

浙公网安备 33010602011771号