maven父工程
- 一般最上面是定义的属性
- 然后是版本管理
- 然后是模块聚合
父工程一般只需要留一个pom.xml文件就行了。
父工程主要是用于版本管理和模块聚合。
一般最上面是定义的属性
属性中写的是各个依赖的版本,方便下面引用。
<properties><java.version>1.8</java.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><spring-boot.version>2.3.7.RELEASE</spring-boot.version><spring-cloud.version>Hoxton.SR9</spring-cloud.version><org.mapstruct.version>1.3.1.Final</org.mapstruct.version><spring-cloud-alibaba.version>2.2.6.RELEASE</spring-cloud-alibaba.version><org.projectlombok.version>1.18.8</org.projectlombok.version><javax.servlet-api.version>4.0.1</javax.servlet-api.version><fastjson.version>1.2.83</fastjson.version><druid-spring-boot-starter.version>1.2.8</druid-spring-boot-starter.version><mysql-connector-java.version>8.0.30</mysql-connector-java.version><mybatis-plus-boot-starter.version>3.4.1</mybatis-plus-boot-starter.version><commons-lang.version>2.6</commons-lang.version><minio.version>8.4.3</minio.version><xxl-job-core.version>2.3.1</xxl-job-core.version><swagger-annotations.version>1.5.20</swagger-annotations.version><commons-lang3.version>3.10</commons-lang3.version><okhttp.version>4.8.1</okhttp.version><swagger-spring-boot-starter.version>1.9.0.RELEASE</swagger-spring-boot-starter.version><elasticsearch.version>7.12.1</elasticsearch.version></properties>
然后是版本管理
<dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency><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>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-dependencies</artifactId><version>${spring-cloud-alibaba.version}</version><type>pom</type><scope>import</scope></dependency><!-- lombok,简化类的构建--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>${org.projectlombok.version}</version></dependency><!-- mapstruct 代码生成器,简化java bean之间的映射 --><dependency><groupId>org.mapstruct</groupId><artifactId>mapstruct-jdk8</artifactId><version>${org.mapstruct.version}</version></dependency><dependency><groupId>org.mapstruct</groupId><artifactId>mapstruct-processor</artifactId><version>${org.mapstruct.version}</version></dependency><dependency><groupId>io.swagger</groupId><artifactId>swagger-annotations</artifactId><version>${swagger-annotations.version}</version></dependency><!-- Servlet 容器管理 --><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>${javax.servlet-api.version}</version><scope>provided</scope></dependency><!-- fastjson ,json解析工具 --><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>${fastjson.version}</version></dependency><!-- druid 连接池管理 --><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>${druid-spring-boot-starter.version}</version></dependency><!-- mySQL数据库驱动包管理 --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>${mysql-connector-java.version}</version></dependency><!-- mybatis plus 集成Spring Boot启动器 --><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>${mybatis-plus-boot-starter.version}</version></dependency><!-- mybatis plus 代码生成器 --><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-generator</artifactId><version>${mybatis-plus-boot-starter.version}</version></dependency><!-- 工具类管理 --><dependency><groupId>commons-lang</groupId><artifactId>commons-lang</artifactId><version>${commons-lang.version}</version></dependency><!-- 分布式文件系统 minIO的客户端API包 --><dependency><groupId>io.minio</groupId><artifactId>minio</artifactId><version>${minio.version}</version></dependency><!--google推荐的一套工具类库--><dependency><groupId>com.google.guava</groupId><artifactId>guava</artifactId><version>25.0-jre</version></dependency><!--分布式任务调度--><dependency><groupId>com.xuxueli</groupId><artifactId>xxl-job-core</artifactId><version>${xxl-job-core.version}</version></dependency><!--Spring boot单元测试--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><version>${spring-boot.version}</version><scope>test</scope><exclusions><exclusion><groupId>org.junit.vintage</groupId><artifactId>junit-vintage-engine</artifactId></exclusion></exclusions></dependency><dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp</artifactId><version>${okhttp.version}</version></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>${commons-lang3.version}</version></dependency><dependency><groupId>com.spring4all</groupId><artifactId>swagger-spring-boot-starter</artifactId><version>${swagger-spring-boot-starter.version}</version></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId><version>${elasticsearch.version}</version></dependency><dependency><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId><version>${elasticsearch.version}</version></dependency></dependencies></dependencyManagement>
然后是模块聚合
<moudles><moudle></moudle></moudles>