SpringBoot聚合父工程的子模块依赖问题解决过程
聚合模块规则
本文纯粹为了记载开发中的问题,所以可读性比较差,可能只有本人能看明白。
1. 创建父模块,在porm.xml中的下面内容
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.5</version> <relativePath/> <!-- lookup parent from repository --> </parent>
2. 创建子模块,子模块的父模块的porm.xml会体现父模块
3.创建子模块下的子模块
4.附加的全局模块common
说明:全局模块在maven中install的的时候,因为是全依赖状态,所以能很顺利的完成。
5.创建全局模块中的子模块
6.添加依赖
-
1.在父模块中有子模块的体现
<modules> <module>service</module> <module>common</module> </modules>
-
2.在子模块中添加下属子模块的依赖 3.在子模块中添加全局模块的依赖
7.出现问题
-
找不到com.XXX.XXX程序包(前提是在模块中用import导入了全局模块的包,因为某些问题,所以找不到这个包。需要在全局模块的对应子模块中添加打包插件
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <classifier>exec</classifier> </configuration> </plugin> </plugins> </build> ```
下一篇:
冒泡排序(java)——3种方法