Maven管理SpringBoot项目-父子工程(依赖处理)
工程大概目录
父工程配置
<?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.xie</ groupId>
< artifactId> backend-template</ artifactId>
< version> ${revision}</ version>
< name> backend-template</ name>
< url> https://gitee.com/eminem-my-love/backend-template</ url>
< description> 沉淀</ description>
< properties>
< revision> 0.0.1-SNAPSHOT</ revision>
< spring-boot.version> 3.0.8</ spring-boot.version>
< project.build.sourceEncoding> UTF-8</ project.build.sourceEncoding>
< project.reporting.outputEncoding> UTF-8</ project.reporting.outputEncoding>
< java.version> 17</ java.version>
< lombok.version> 1.18.26</ lombok.version>
< maven-jar-plugin.version> 3.2.2</ maven-jar-plugin.version>
< maven-war-plugin.version> 3.2.2</ maven-war-plugin.version>
< maven-compiler-plugin.verison> 3.11.0</ maven-compiler-plugin.verison>
< maven-surefire-plugin.version> 3.0.0</ maven-surefire-plugin.version>
< flatten-maven-plugin.version> 1.3.0</ flatten-maven-plugin.version>
</ properties>
< profiles>
< profile>
< id> local</ id>
< properties>
< profiles.active> local</ profiles.active>
< logging.level> debug</ logging.level>
</ properties>
</ profile>
< profile>
< id> dev</ id>
< properties>
< profiles.active> dev</ profiles.active>
< logging.level> debug</ logging.level>
</ properties>
< activation>
< activeByDefault> true</ activeByDefault>
</ activation>
</ profile>
< profile>
< id> prod</ id>
< properties>
< profiles.active> prod</ profiles.active>
< logging.level> warn</ logging.level>
</ properties>
</ profile>
</ profiles>
< dependencyManagement>
< dependencies>
< dependency>
< groupId> org.springframework.boot</ groupId>
< artifactId> spring-boot-dependencies</ artifactId>
< version> ${spring-boot.version}</ version>
< type> pom</ type>
< scope> import</ scope>
</ dependency>
< dependency>
< groupId> org.projectlombok</ groupId>
< artifactId> lombok</ artifactId>
< version> ${lombok.version}</ version>
</ dependency>
< dependency>
< groupId> com.xie</ groupId>
< artifactId> pure-system</ artifactId>
< version> ${revision}</ version>
</ dependency>
< dependency>
< groupId> com.xie</ groupId>
< artifactId> pure-common-bom</ artifactId>
< version> ${revision}</ version>
< type> pom</ type>
< scope> import</ scope>
</ dependency>
</ dependencies>
</ dependencyManagement>
< modules>
< module> pure-admin</ module>
< module> pure-common</ module>
< module> pure-module</ module>
</ modules>
< packaging> pom</ packaging>
< build>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins</ groupId>
< artifactId> maven-compiler-plugin</ artifactId>
< version> ${maven-compiler-plugin.verison}</ version>
< configuration>
< source> ${java.version}</ source>
< target> ${java.version}</ target>
< encoding> ${project.build.sourceEncoding}</ encoding>
< compilerArgs>
< arg> -parameters</ arg>
</ compilerArgs>
</ configuration>
</ plugin>
< plugin>
< groupId> org.apache.maven.plugins</ groupId>
< artifactId> maven-surefire-plugin</ artifactId>
< version> ${maven-surefire-plugin.version}</ version>
</ plugin>
< plugin>
< groupId> org.codehaus.mojo</ groupId>
< artifactId> flatten-maven-plugin</ artifactId>
< version> ${flatten-maven-plugin.version}</ version>
< configuration>
< updatePomFile> true</ updatePomFile>
< flattenMode> resolveCiFriendliesOnly</ flattenMode>
</ configuration>
< executions>
< execution>
< id> flatten</ id>
< phase> process-resources</ phase>
< goals>
< goal> flatten</ goal>
</ goals>
</ execution>
< execution>
< id> flatten.clean</ id>
< phase> clean</ phase>
< goals>
< goal> clean</ goal>
</ goals>
</ execution>
</ executions>
</ plugin>
</ plugins>
< resources>
< resource>
< directory> src/main/resources</ directory>
< filtering> false</ filtering>
</ resource>
< resource>
< directory> src/main/resources</ directory>
< includes>
< include> application*</ include>
< include> bootstrap*</ include>
< include> banner*</ include>
</ includes>
< filtering> true</ filtering>
</ resource>
</ resources>
</ build>
< repositories>
< repository>
< id> public</ id>
< name> huawei nexus</ name>
< url> https://mirrors.huaweicloud.com/repository/maven/</ url>
< releases>
< enabled> true</ enabled>
</ releases>
</ repository>
</ repositories>
< pluginRepositories>
< pluginRepository>
< id> public</ id>
< name> huawei nexus</ name>
< url> https://mirrors.huaweicloud.com/repository/maven/</ url>
< releases>
< enabled> true</ enabled>
</ releases>
< snapshots>
< enabled> false</ enabled>
</ snapshots>
</ pluginRepository>
</ pluginRepositories>
</ project>
common包配置
<?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>
< parent>
< groupId> com.xie</ groupId>
< artifactId> backend-template</ artifactId>
< version> ${revision}</ version>
</ parent>
< artifactId> pure-common</ artifactId>
< packaging> pom</ packaging>
< description>
common 通用模块
</ description>
< modules>
< module> pure-common-bom</ module>
< module> pure-common-core</ module>
< module> pure-common-doc</ module>
< module> pure-common-web</ module>
</ modules>
</ project>
common中bom配置-注意
<?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.xie</ groupId>
< artifactId> pure-common-bom</ artifactId>
< version> ${revision}</ version>
< packaging> pom</ packaging>
< name> pure-common-bom</ name>
< properties>
< revision> 0.0.1-SNAPSHOT</ revision>
</ properties>
< dependencyManagement>
< dependencies>
< dependency>
< groupId> com.xie</ groupId>
< artifactId> pure-common-core</ artifactId>
< version> ${revision}</ version>
</ dependency>
< dependency>
< groupId> com.xie</ groupId>
< artifactId> pure-common-web</ artifactId>
< version> ${revision}</ version>
</ dependency>
< dependency>
< groupId> com.xie</ groupId>
< artifactId> pure-common-doc</ artifactId>
< version> ${revision}</ version>
</ dependency>
</ dependencies>
</ dependencyManagement>
</ project>
common-web
< 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" >
< parent>
< groupId> com.xie</ groupId>
< artifactId> pure-common</ artifactId>
< version> ${revision}</ version>
</ parent>
< modelVersion> 4.0.0</ modelVersion>
< artifactId> pure-common-web</ artifactId>
< description>
pure-common-web web服务
</ description>
< dependencies>
< dependency>
< groupId> org.springframework.boot</ groupId>
< artifactId> spring-boot-starter-web</ artifactId>
</ dependency>
</ dependencies>
</ project>
注意bom在父工程中导入
< dependency>
< groupId> com.xie</ groupId>
< artifactId> pure-common-bom</ artifactId>
< version> ${revision}</ version>
< type> pom</ type>
< scope> import</ scope>
</ dependency>
注意bom在父工程中导入
< dependency>
< groupId> com.xie</ groupId>
< artifactId> pure-common-bom</ artifactId>
< version> ${revision}</ version>
< type> pom</ type>
< scope> import</ scope>
</ dependency>
git项目地址