主pom文件关键点分析
- properties标签声明变量信息:版本号、编码类型、java版本
- spring-boot依赖形式:spring-boot-dependencies、pom、import
- dependencies中添加本项目内部模块,同时在modules中声明模块
- packaging打包选择pom
- 设置打包maven-compiler-plugin相关配置
- 添加阿里云仓库作为项目仓库和插件仓库
<project><groupId>com.ruoyi</groupId><artifactId>ruoyi</artifactId><version>3.8.7</version><properties><ruoyi.version>3.8.7</ruoyi.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version><maven-jar-plugin.version>3.1.1</maven-jar-plugin.version><druid.version>1.2.20</druid.version><bitwalker.version>1.21</bitwalker.version><swagger.version>3.0.0</swagger.version><kaptcha.version>2.3.3</kaptcha.version><pagehelper.boot.version>1.4.7</pagehelper.boot.version><fastjson.version>2.0.43</fastjson.version><oshi.version>6.4.8</oshi.version><commons.io.version>2.13.0</commons.io.version><commons.collections.version>3.2.2</commons.collections.version><poi.version>4.1.2</poi.version><velocity.version>2.3</velocity.version><jwt.version>0.9.1</jwt.version></properties><dependencyManagement><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>2.5.15</version><type>pom</type><scope>import</scope></dependency><!-- 省略其他项目依赖-->......<!-- 定时任务--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-quartz</artifactId><version>${ruoyi.version}</version></dependency><!-- 代码生成--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-generator</artifactId><version>${ruoyi.version}</version></dependency><!-- 核心模块--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-framework</artifactId><version>${ruoyi.version}</version></dependency><!-- 系统模块--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-system</artifactId><version>${ruoyi.version}</version></dependency><!-- 通用工具--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-common</artifactId><version>${ruoyi.version}</version></dependency></dependencies></dependencyManagement><modules><module>ruoyi-admin</module><module>ruoyi-framework</module><module>ruoyi-system</module><module>ruoyi-quartz</module><module>ruoyi-generator</module><module>ruoyi-common</module></modules><packaging>pom</packaging><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.1</version><configuration><source>${java.version}</source><target>${java.version}</target><encoding>${project.build.sourceEncoding}</encoding></configuration></plugin></plugins></build><repositories><repository><id>public</id><name>aliyun nexus</name><url>https://maven.aliyun.com/repository/public</url><releases><enabled>true</enabled></releases></repository></repositories><pluginRepositories><pluginRepository><id>public</id><name>aliyun nexus</name><url>https://maven.aliyun.com/repository/public</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></pluginRepository></pluginRepositories></project>
模块间依赖关系
- 每个模块在自己的pom文件中添加dependency依赖即可,不用写版本号,已经统一在主pom中管理。
- 每个模块将主pom文件的包标识作为自己的parent标签内容
- 入口包(admin)的pom文件中packaging为jar