spring boot + maven配置, 创建一个包含多个模块项目的步骤
项目创建
使用spring的initializr 选择一下就可以生成代码
- 项目:
tongda (jar) - 模块:
user (war)
order (war)
common (jar)
配置:
- Project : Maven Project
- Language : Java
- Spring Boot : 2.4.1
- Dependencies:
- Java : 11
- Packaging :jar/war
调整 parent POM
修改tongda的pom.xml
, 打包类型设置为pom
- 新增
packaging
标签并设置为pom
<packaging>pom</packaging>
- 通知增加模块配置
<modules>
<module>user</module>
<module>order</module>
<module>common</module>
</modules>
- 各个模块中调整
parent
标签
order
, user
模块 pom.xml
文件
<parent>
<groupId>com.tongda</groupId>
<artifactId>tongda</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- 验证
> mvn clean package
...
[INFO] Reactor Summary:
[INFO]
[INFO] tongda 0.0.1-SNAPSHOT .............................. SUCCESS [ 1.250 s]
[INFO] user ............................................... SUCCESS [ 9.161 s]
[INFO] order .............................................. SUCCESS [ 6.106 s]
[INFO] common 0.0.1-SNAPSHOT .............................. SUCCESS [ 4.226 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
...
参考引用
https://www.baeldung.com/maven-multi-module
https://github.com/bz51/SpringBoot-Dubbo-Docker-Jenkins
Photo by Zaksheuskaya from Pexels
Comments are closed.