明确子父模块结构
父目录是带modules
大致结构如下:
<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><module>ruoyi-ems</module></modules><packaging>pom</packaging>
像打包出现这样的报错就是子模块打包方式使用了pom
Failure to find com.ruoyi:ruoyi-framework:jar:3.8.5 in https://maven.aliyun.com/repository/public was cached in the local repository, resolution will not be reattempted until the update interval of public has elapsed or updates are forced
应该使用jar的打包方式。
jar,war,pom的区别
JAR、WAR 和 POM 是 Java 开发中常见的三种文件类型,它们在项目构建和部署过程中起着不同的作用。
-
JAR(Java Archive):JAR 文件是一种用于存储 Java 类、资源文件和库的归档文件格式。它通常用于打包和发布 Java 应用程序、库或模块。JAR 文件可以包含多个类文件和相关的资源文件,并且可以通过 Java 虚拟机(JVM)来运行。JAR 文件可以被其他 Java 项目依赖引用,使得代码复用和模块化开发更加方便。
-
WAR(Web Application Archive):WAR 文件是一种用于打包和部署 Web 应用程序的归档文件格式。WAR 文件中包含了 Web 应用程序的 Java 类、资源文件、静态资源(如 HTML、CSS、JavaScript 文件)以及部署描述符(如 web.xml)。WAR 文件可以被部署到支持 Java Servlet 规范的 Web 容器(如 Tomcat、Jetty)中,并通过容器提供的 HTTP 服务来访问 Web 应用程序。
-
POM(Project Object Model):POM 是 Maven 构建工具使用的 XML 文件,用于定义和管理项目的各种元数据和配置信息。POM 文件描述了项目的依赖关系、构建生命周期、插件配置、仓库信息等。它是 Maven 构建过程中的核心文件,通过读取和解析 POM 文件,Maven 可以自动化地执行编译、测试、打包、部署等操作。
总结:
- JAR 是用于打包 Java 类和相关资源的归档文件格式,用于代码的发布和复用。
- WAR 是用于打包和部署 Web 应用程序的归档文件格式,包含了 Web 相关的类、资源和描述符,用于 Web 应用的部署和访问。
- POM 是 Maven 项目的配置文件,用于定义项目的元数据和构建配置,通过读取和解析 POM 文件,Maven 可以自动化地完成各种构建任务。
配置pom打包方式的意思是使用maven分模块管理,都会有一个父级项目,pom文件一个重要的属性就是packaging(打包类型),一般来说所有的父级项目的packaging都为pom,packaging默认类型jar类型,如果不做配置,maven会将该项目打成jar包。
子模块都是jar包
父模块是ruoyi,其它都是子模块。
有时需要按照顺序clean 和 install。我这里都配置好了,只要在父工程中install就行。然后就会获得一个target文件夹,里面有我们要的打包好的程序jar包
admin模块细节部分:
会有build部分
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>2.1.1.RELEASE</version><configuration><fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
<!-- <mainClass>com.ruoyi.RuoYiApplication</mainClass>--></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>3.1.0</version><configuration><failOnMissingWebXml>false</failOnMissingWebXml><warName>${project.artifactId}</warName></configuration></plugin></plugins><finalName>${project.artifactId}</finalName></build>
贴出所有的pom.xml文件吧
common的
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://maven.apache.org/POM/4.0.0"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>ruoyi</artifactId><groupId>com.ruoyi</groupId><version>3.8.5</version>
<!-- <relativePath>../pom.xml</relativePath>--></parent><modelVersion>4.0.0</modelVersion><artifactId>ruoyi-common</artifactId><packaging>jar</packaging><description>common通用工具</description><dependencies><!-- Spring框架基本的核心工具 --><dependency><groupId>org.springframework</groupId><artifactId>spring-context-support</artifactId></dependency><!-- SpringWeb模块 --><dependency><groupId>org.springframework</groupId><artifactId>spring-web</artifactId></dependency><!-- spring security 安全认证 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency><!-- pagehelper 分页插件 --><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId></dependency><!-- 自定义验证注解 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-validation</artifactId></dependency><!--常用工具类 --><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId></dependency><!-- JSON工具类 --><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId></dependency><!-- 动态数据源 --><dependency><groupId>com.baomidou</groupId><artifactId>dynamic-datasource-spring-boot-starter</artifactId><version>3.5.2</version></dependency><!-- 阿里JSON解析器 --><dependency><groupId>com.alibaba.fastjson2</groupId><artifactId>fastjson2</artifactId></dependency><!-- io常用工具类 --><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId></dependency><!-- excel工具 --><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId></dependency><!-- yml解析器 --><dependency><groupId>org.yaml</groupId><artifactId>snakeyaml</artifactId></dependency><!-- Token生成与解析--><dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt</artifactId></dependency><!-- Jaxb --><dependency><groupId>javax.xml.bind</groupId><artifactId>jaxb-api</artifactId></dependency><!-- redis 缓存操作 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency><!-- pool 对象池 --><dependency><groupId>org.apache.commons</groupId><artifactId>commons-pool2</artifactId></dependency><!-- 解析客户端操作系统、浏览器等 --><dependency><groupId>eu.bitwalker</groupId><artifactId>UserAgentUtils</artifactId></dependency><!-- servlet包 --><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId></dependency></dependencies></project>
system的
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://maven.apache.org/POM/4.0.0"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>ruoyi</artifactId><groupId>com.ruoyi</groupId><version>3.8.5</version></parent><modelVersion>4.0.0</modelVersion><packaging>jar</packaging><artifactId>ruoyi-system</artifactId><description>system系统模块</description><dependencies><!-- 通用工具--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-common</artifactId></dependency></dependencies></project>
quartz
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://maven.apache.org/POM/4.0.0"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>ruoyi</artifactId><groupId>com.ruoyi</groupId><version>3.8.5</version></parent><modelVersion>4.0.0</modelVersion><artifactId>ruoyi-quartz</artifactId><packaging>jar</packaging><description>quartz定时任务</description><dependencies><!-- 定时任务 --><dependency><groupId>org.quartz-scheduler</groupId><artifactId>quartz</artifactId><exclusions><exclusion><groupId>com.mchange</groupId><artifactId>c3p0</artifactId></exclusion></exclusions></dependency><!-- 通用工具--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-common</artifactId></dependency></dependencies></project>
generator的
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://maven.apache.org/POM/4.0.0"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>ruoyi</artifactId><groupId>com.ruoyi</groupId><version>3.8.5</version></parent><modelVersion>4.0.0</modelVersion><artifactId>ruoyi-generator</artifactId><packaging>jar</packaging><description>generator代码生成</description><dependencies><!--velocity代码生成使用模板 --><dependency><groupId>org.apache.velocity</groupId><artifactId>velocity-engine-core</artifactId></dependency><!-- collections工具类 --><dependency><groupId>commons-collections</groupId><artifactId>commons-collections</artifactId></dependency><!-- 通用工具--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-common</artifactId></dependency></dependencies></project>
framwork的
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://maven.apache.org/POM/4.0.0"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>ruoyi</artifactId><groupId>com.ruoyi</groupId><version>3.8.5</version></parent><modelVersion>4.0.0</modelVersion><artifactId>ruoyi-framework</artifactId><packaging>jar</packaging><description>framework框架核心</description><dependencies><!-- SpringBoot Web容器 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!-- SpringBoot 拦截器 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-aop</artifactId></dependency><!-- 阿里数据库连接池 --><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId></dependency><!-- 验证码 --><dependency><groupId>pro.fessional</groupId><artifactId>kaptcha</artifactId><exclusions><exclusion><artifactId>javax.servlet-api</artifactId><groupId>javax.servlet</groupId></exclusion></exclusions></dependency><!-- 获取系统信息 --><dependency><groupId>com.github.oshi</groupId><artifactId>oshi-core</artifactId></dependency><!-- 系统模块--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-system</artifactId></dependency></dependencies></project>
ems的
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://maven.apache.org/POM/4.0.0"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.ruoyi</groupId><artifactId>ruoyi</artifactId><version>3.8.5</version></parent><artifactId>ruoyi-ems</artifactId><packaging>jar</packaging><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><!-- spring-boot-devtools --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional> <!-- 表示依赖不会传递 --></dependency><!-- swagger3--><dependency><groupId>io.springfox</groupId><artifactId>springfox-boot-starter</artifactId></dependency><!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 --><dependency><groupId>io.swagger</groupId><artifactId>swagger-models</artifactId><version>1.6.2</version></dependency><!-- Mysql驱动包 --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><!-- 核心模块--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-framework</artifactId></dependency><!-- 定时任务--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-quartz</artifactId></dependency><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-common</artifactId></dependency></dependencies></project>
admin的
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://maven.apache.org/POM/4.0.0"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>ruoyi</artifactId><groupId>com.ruoyi</groupId><version>3.8.5</version></parent><modelVersion>4.0.0</modelVersion><packaging>jar</packaging><artifactId>ruoyi-admin</artifactId><!-- <modules>-->
<!-- <module>../ruoyi-common</module>-->
<!-- <module>../ruoyi-ems</module>-->
<!-- <module>../ruoyi-framework</module>-->
<!-- <module>../ruoyi-generator</module>-->
<!-- <module>../ruoyi-quartz</module>-->
<!-- <module>../ruoyi-system</module>-->
<!-- </modules>--><description>web服务入口</description><dependencies><!-- spring-boot-devtools --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional> <!-- 表示依赖不会传递 --></dependency><!-- swagger3--><dependency><groupId>io.springfox</groupId><artifactId>springfox-boot-starter</artifactId></dependency><!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 --><dependency><groupId>io.swagger</groupId><artifactId>swagger-models</artifactId><version>1.6.2</version></dependency><!-- Mysql驱动包 --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><!-- 核心模块--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-framework</artifactId></dependency><!-- 定时任务--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-quartz</artifactId></dependency><!-- 代码生成--><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-generator</artifactId></dependency><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-ems</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>2.1.1.RELEASE</version><configuration><fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
<!-- <mainClass>com.ruoyi.RuoYiApplication</mainClass>--></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>3.1.0</version><configuration><failOnMissingWebXml>false</failOnMissingWebXml><warName>${project.artifactId}</warName></configuration></plugin></plugins><finalName>${project.artifactId}</finalName></build></project>
最后是父pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://maven.apache.org/POM/4.0.0"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.ruoyi</groupId><artifactId>ruoyi</artifactId><version>3.8.5</version><name>ruoyi</name><url>http://www.ruoyi.vip</url><description>若依管理系统</description><properties><ruoyi.version>3.8.5</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.16</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.6</pagehelper.boot.version><fastjson.version>2.0.23</fastjson.version><oshi.version>6.4.0</oshi.version><commons.io.version>2.11.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><!-- SpringBoot的依赖配置--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>2.5.14</version><type>pom</type><scope>import</scope></dependency><!-- 阿里数据库连接池 --><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>${druid.version}</version></dependency><!-- 解析客户端操作系统、浏览器等 --><dependency><groupId>eu.bitwalker</groupId><artifactId>UserAgentUtils</artifactId><version>${bitwalker.version}</version></dependency><!-- pagehelper 分页插件 --><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>${pagehelper.boot.version}</version></dependency><!-- 获取系统信息 --><dependency><groupId>com.github.oshi</groupId><artifactId>oshi-core</artifactId><version>${oshi.version}</version></dependency><!-- Swagger3依赖 --><dependency><groupId>io.springfox</groupId><artifactId>springfox-boot-starter</artifactId><version>${swagger.version}</version><exclusions><exclusion><groupId>io.swagger</groupId><artifactId>swagger-models</artifactId></exclusion></exclusions></dependency><!-- io常用工具类 --><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>${commons.io.version}</version></dependency><!-- excel工具 --><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>${poi.version}</version></dependency><!-- velocity代码生成使用模板 --><dependency><groupId>org.apache.velocity</groupId><artifactId>velocity-engine-core</artifactId><version>${velocity.version}</version></dependency><!-- collections工具类 --><dependency><groupId>commons-collections</groupId><artifactId>commons-collections</artifactId><version>${commons.collections.version}</version></dependency><!-- 阿里JSON解析器 --><dependency><groupId>com.alibaba.fastjson2</groupId><artifactId>fastjson2</artifactId><version>${fastjson.version}</version></dependency><!-- Token生成与解析--><dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt</artifactId><version>${jwt.version}</version></dependency><!-- 验证码 --><dependency><groupId>pro.fessional</groupId><artifactId>kaptcha</artifactId><version>${kaptcha.version}</version></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><dependency><groupId>com.ruoyi</groupId><artifactId>ruoyi-ems</artifactId><version>3.8.5</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><module>ruoyi-ems</module></modules><packaging>pom</packaging><dependencies></dependencies><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>
所以打包顺序也是common-system-quartz-generator-framework-ems-admin-父pom