父工程建一个最简单的New project就可以了,不需要生成Spring Initializr模板
父工程的用处就是对子工程的maven进行管理,所以关键的文件只有一个pom.xml,一共就两个配置
1、一个在<modules>标签下写入所有要管理的子工程,用于聚合
2、将打包方式更改为pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cyk</groupId>
<artifactId>springAMQP</artifactId>
<version>1.0-SNAPSHOT</version>
<!--写入子工程目录,用于在项目打包时聚合,一次性打包-->
<modules>
<module>consumer</module>
<module>publisher</module>
</modules>
<!--父工程需要更改打包方式为pom-->
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.9.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
子工程pom.xml就一个配置,选定父工程的pom位置即可
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<!--父工程位置-->
<groupId>com.cyk</groupId>
<artifactId>springAMQP</artifactId>
<version>1.0-SNAPSHOT</version>
<!--父工程pom.xml相对路径-->
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>publisher</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
标签:xml,工程,spring,boot,pom,构建,Spring,SNAPSHOT From: https://www.cnblogs.com/cyknote/p/18057306