springboot多模块打包方式

明确子父模块结构

父目录是带modules
大致结构如下:

   
        ruoyi-admin
        ruoyi-framework
        ruoyi-system
        ruoyi-quartz
        ruoyi-generator
        ruoyi-common
        ruoyi-ems
    
    pom

像打包出现这样的报错就是子模块打包方式使用了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 开发中常见的三种文件类型,它们在项目构建和部署过程中起着不同的作用。

  1. JAR(Java Archive):JAR 文件是一种用于存储 Java 类、资源文件和库的归档文件格式。它通常用于打包和发布 Java 应用程序、库或模块。JAR 文件可以包含多个类文件和相关的资源文件,并且可以通过 Java 虚拟机(JVM)来运行。JAR 文件可以被其他 Java 项目依赖引用,使得代码复用和模块化开发更加方便。

  2. WAR(Web Application Archive):WAR 文件是一种用于打包和部署 Web 应用程序的归档文件格式。WAR 文件中包含了 Web 应用程序的 Java 类、资源文件、静态资源(如 HTML、CSS、JavaScript 文件)以及部署描述符(如 web.xml)。WAR 文件可以被部署到支持 Java Servlet 规范的 Web 容器(如 Tomcat、Jetty)中,并通过容器提供的 HTTP 服务来访问 Web 应用程序。

  3. 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包
springboot多模块打包方式_第1张图片
父模块是ruoyi,其它都是子模块。
有时需要按照顺序clean 和 install。我这里都配置好了,只要在父工程中install就行。然后就会获得一个target文件夹,里面有我们要的打包好的程序jar包

admin模块细节部分:
会有build部分

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
                <version>2.1.1.RELEASEversion>
                <configuration>
                    <fork>truefork> 

                configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackagegoal>
                        goals>
                    execution>
                executions>
            plugin>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-war-pluginartifactId>
                <version>3.1.0version>
                <configuration>
                    <failOnMissingWebXml>falsefailOnMissingWebXml>
                    <warName>${project.artifactId}warName>
                configuration>
           plugin>
        plugins>
        <finalName>${project.artifactId}finalName>
    build>

贴出所有的pom.xml文件吧
common的


<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>ruoyiartifactId>
        <groupId>com.ruoyigroupId>
        <version>3.8.5version>


    parent>
    <modelVersion>4.0.0modelVersion>

    <artifactId>ruoyi-commonartifactId>
    <packaging>jarpackaging>

    <description>
        common通用工具
    description>

    <dependencies>

        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-context-supportartifactId>
        dependency>

        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-webartifactId>
        dependency>

        
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-securityartifactId>
        dependency>

        
        <dependency>
            <groupId>com.github.pagehelpergroupId>
            <artifactId>pagehelper-spring-boot-starterartifactId>
        dependency>

        
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-validationartifactId>
        dependency>

        
        <dependency>
            <groupId>org.apache.commonsgroupId>
            <artifactId>commons-lang3artifactId>
        dependency>

        
        <dependency>
            <groupId>com.fasterxml.jackson.coregroupId>
            <artifactId>jackson-databindartifactId>
        dependency>

        
		<dependency>
			<groupId>com.baomidougroupId>
			<artifactId>dynamic-datasource-spring-boot-starterartifactId>
			<version>3.5.2version>
		dependency>

        
        <dependency>
            <groupId>com.alibaba.fastjson2groupId>
            <artifactId>fastjson2artifactId>
        dependency>

        
        <dependency>
            <groupId>commons-iogroupId>
            <artifactId>commons-ioartifactId>
        dependency>

        
        <dependency>
            <groupId>org.apache.poigroupId>
            <artifactId>poi-ooxmlartifactId>
        dependency>

        
        <dependency>
            <groupId>org.yamlgroupId>
            <artifactId>snakeyamlartifactId>
        dependency>

        
        <dependency>
            <groupId>io.jsonwebtokengroupId>
            <artifactId>jjwtartifactId>
        dependency>

        
        <dependency>
            <groupId>javax.xml.bindgroupId>
            <artifactId>jaxb-apiartifactId>
        dependency>

        
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-data-redisartifactId>
        dependency>

        
        <dependency>
            <groupId>org.apache.commonsgroupId>
            <artifactId>commons-pool2artifactId>
        dependency>

        
        <dependency>
            <groupId>eu.bitwalkergroupId>
            <artifactId>UserAgentUtilsartifactId>
        dependency>

        
        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>javax.servlet-apiartifactId>
        dependency>

    dependencies>

project>

system的


<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>ruoyiartifactId>
        <groupId>com.ruoyigroupId>
        <version>3.8.5version>
    parent>
    <modelVersion>4.0.0modelVersion>

    <packaging>jarpackaging>

    <artifactId>ruoyi-systemartifactId>

    <description>
        system系统模块
    description>

    <dependencies>

        
        <dependency>
            <groupId>com.ruoyigroupId>
            <artifactId>ruoyi-commonartifactId>
        dependency>

    dependencies>

project>

quartz


<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>ruoyiartifactId>
        <groupId>com.ruoyigroupId>
        <version>3.8.5version>
    parent>
    <modelVersion>4.0.0modelVersion>

    <artifactId>ruoyi-quartzartifactId>
    <packaging>jarpackaging>

    <description>
        quartz定时任务
    description>

    <dependencies>

        
        <dependency>
            <groupId>org.quartz-schedulergroupId>
            <artifactId>quartzartifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.mchangegroupId>
                    <artifactId>c3p0artifactId>
                exclusion>
            exclusions>
        dependency>

        
        <dependency>
            <groupId>com.ruoyigroupId>
            <artifactId>ruoyi-commonartifactId>
        dependency>

    dependencies>

project>

generator的



    
        ruoyi
        com.ruoyi
        3.8.5
    
    4.0.0

    ruoyi-generator
    jar

    
        generator代码生成
    

    

        
        
            org.apache.velocity
            velocity-engine-core
        

        
        
            commons-collections
            commons-collections
        

        
        
            com.ruoyi
            ruoyi-common
        

    



framwork的


<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>ruoyiartifactId>
        <groupId>com.ruoyigroupId>
        <version>3.8.5version>
    parent>
    <modelVersion>4.0.0modelVersion>

    <artifactId>ruoyi-frameworkartifactId>
    <packaging>jarpackaging>
    <description>
        framework框架核心
    description>

    <dependencies>

        
         <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>

        
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-aopartifactId>
        dependency>

        
        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>druid-spring-boot-starterartifactId>
        dependency>

        
        <dependency>
            <groupId>pro.fessionalgroupId>
            <artifactId>kaptchaartifactId>
            <exclusions>
                <exclusion>
                    <artifactId>javax.servlet-apiartifactId>
                    <groupId>javax.servletgroupId>
                exclusion>
            exclusions>
        dependency>

        
        <dependency>
            <groupId>com.github.oshigroupId>
            <artifactId>oshi-coreartifactId>
        dependency>

        
        <dependency>
            <groupId>com.ruoyigroupId>
            <artifactId>ruoyi-systemartifactId>
        dependency>

    dependencies>

project>

ems的


<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.0modelVersion>
    <parent>
        <groupId>com.ruoyigroupId>
        <artifactId>ruoyiartifactId>
        <version>3.8.5version>
    parent>

    <artifactId>ruoyi-emsartifactId>
    <packaging>jarpackaging>

    <properties>
        <maven.compiler.source>8maven.compiler.source>
        <maven.compiler.target>8maven.compiler.target>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    properties>
    <dependencies>

        
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-devtoolsartifactId>
            <optional>trueoptional> 
        dependency>

        
        <dependency>
            <groupId>io.springfoxgroupId>
            <artifactId>springfox-boot-starterartifactId>
        dependency>

        
        <dependency>
            <groupId>io.swaggergroupId>
            <artifactId>swagger-modelsartifactId>
            <version>1.6.2version>
        dependency>

        
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
        dependency>

        
        <dependency>
            <groupId>com.ruoyigroupId>
            <artifactId>ruoyi-frameworkartifactId>
        dependency>

        
        <dependency>
            <groupId>com.ruoyigroupId>
            <artifactId>ruoyi-quartzartifactId>
        dependency>

        <dependency>
            <groupId>com.ruoyigroupId>
            <artifactId>ruoyi-commonartifactId>
        dependency>
    dependencies>

project>

admin的


<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>ruoyiartifactId>
        <groupId>com.ruoyigroupId>
        <version>3.8.5version>
    parent>
    <modelVersion>4.0.0modelVersion>
    <packaging>jarpackaging>
    <artifactId>ruoyi-adminartifactId>











    <description>
        web服务入口
    description>

    <dependencies>

        
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-devtoolsartifactId>
            <optional>trueoptional> 
        dependency>

        
        <dependency>
            <groupId>io.springfoxgroupId>
            <artifactId>springfox-boot-starterartifactId>
        dependency>

        
        <dependency>
            <groupId>io.swaggergroupId>
            <artifactId>swagger-modelsartifactId>
            <version>1.6.2version>
        dependency>

         
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
        dependency>

        
        <dependency>
            <groupId>com.ruoyigroupId>
            <artifactId>ruoyi-frameworkartifactId>
        dependency>

        
        <dependency>
            <groupId>com.ruoyigroupId>
            <artifactId>ruoyi-quartzartifactId>
        dependency>

        
        <dependency>
            <groupId>com.ruoyigroupId>
            <artifactId>ruoyi-generatorartifactId>
        dependency>


        <dependency>
            <groupId>com.ruoyigroupId>
            <artifactId>ruoyi-emsartifactId>
        dependency>

    dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
                <version>2.1.1.RELEASEversion>
                <configuration>
                    <fork>truefork> 

                configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackagegoal>
                        goals>
                    execution>
                executions>
            plugin>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-war-pluginartifactId>
                <version>3.1.0version>
                <configuration>
                    <failOnMissingWebXml>falsefailOnMissingWebXml>
                    <warName>${project.artifactId}warName>
                configuration>
           plugin>
        plugins>
        <finalName>${project.artifactId}finalName>
    build>

project>

最后是父pom


<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.0modelVersion>

    <groupId>com.ruoyigroupId>
    <artifactId>ruoyiartifactId>
    <version>3.8.5version>

    <name>ruoyiname>
    <url>http://www.ruoyi.vipurl>
    <description>若依管理系统description>

    <properties>
        <ruoyi.version>3.8.5ruoyi.version>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
        <java.version>1.8java.version>
        <maven-jar-plugin.version>3.1.1maven-jar-plugin.version>
        <druid.version>1.2.16druid.version>
        <bitwalker.version>1.21bitwalker.version>
        <swagger.version>3.0.0swagger.version>
        <kaptcha.version>2.3.3kaptcha.version>
        <pagehelper.boot.version>1.4.6pagehelper.boot.version>
        <fastjson.version>2.0.23fastjson.version>
        <oshi.version>6.4.0oshi.version>
        <commons.io.version>2.11.0commons.io.version>
        <commons.collections.version>3.2.2commons.collections.version>
        <poi.version>4.1.2poi.version>
        <velocity.version>2.3velocity.version>
        <jwt.version>0.9.1jwt.version>
    properties>

    
    <dependencyManagement>
        <dependencies>

            
            <dependency>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-dependenciesartifactId>
                <version>2.5.14version>
                <type>pomtype>
                <scope>importscope>
            dependency>

            
            <dependency>
                <groupId>com.alibabagroupId>
                <artifactId>druid-spring-boot-starterartifactId>
                <version>${druid.version}version>
            dependency>

            
            <dependency>
                <groupId>eu.bitwalkergroupId>
                <artifactId>UserAgentUtilsartifactId>
                <version>${bitwalker.version}version>
            dependency>

            
            <dependency>
                <groupId>com.github.pagehelpergroupId>
                <artifactId>pagehelper-spring-boot-starterartifactId>
                <version>${pagehelper.boot.version}version>
            dependency>

            
            <dependency>
                <groupId>com.github.oshigroupId>
                <artifactId>oshi-coreartifactId>
                <version>${oshi.version}version>
            dependency>

            
            <dependency>
                <groupId>io.springfoxgroupId>
                <artifactId>springfox-boot-starterartifactId>
                <version>${swagger.version}version>
                <exclusions>
                    <exclusion>
                        <groupId>io.swaggergroupId>
                        <artifactId>swagger-modelsartifactId>
                    exclusion>
                exclusions>
            dependency>

            
            <dependency>
                <groupId>commons-iogroupId>
                <artifactId>commons-ioartifactId>
                <version>${commons.io.version}version>
            dependency>

            
            <dependency>
                <groupId>org.apache.poigroupId>
                <artifactId>poi-ooxmlartifactId>
                <version>${poi.version}version>
            dependency>

            
            <dependency>
                <groupId>org.apache.velocitygroupId>
                <artifactId>velocity-engine-coreartifactId>
                <version>${velocity.version}version>
            dependency>

            
            <dependency>
                <groupId>commons-collectionsgroupId>
                <artifactId>commons-collectionsartifactId>
                <version>${commons.collections.version}version>
            dependency>

            
            <dependency>
                <groupId>com.alibaba.fastjson2groupId>
                <artifactId>fastjson2artifactId>
                <version>${fastjson.version}version>
            dependency>

            
            <dependency>
                <groupId>io.jsonwebtokengroupId>
                <artifactId>jjwtartifactId>
                <version>${jwt.version}version>
            dependency>

            
            <dependency>
                <groupId>pro.fessionalgroupId>
                <artifactId>kaptchaartifactId>
                <version>${kaptcha.version}version>
            dependency>

            
            <dependency>
                <groupId>com.ruoyigroupId>
                <artifactId>ruoyi-quartzartifactId>
                <version>${ruoyi.version}version>
            dependency>

            
            <dependency>
                <groupId>com.ruoyigroupId>
                <artifactId>ruoyi-generatorartifactId>
                <version>${ruoyi.version}version>
            dependency>

            
            <dependency>
                <groupId>com.ruoyigroupId>
                <artifactId>ruoyi-frameworkartifactId>
                <version>${ruoyi.version}version>
            dependency>

            
            <dependency>
                <groupId>com.ruoyigroupId>
                <artifactId>ruoyi-systemartifactId>
                <version>${ruoyi.version}version>
            dependency>

            
            <dependency>
                <groupId>com.ruoyigroupId>
                <artifactId>ruoyi-commonartifactId>
                <version>${ruoyi.version}version>
            dependency>

            <dependency>
                <groupId>com.ruoyigroupId>
                <artifactId>ruoyi-emsartifactId>
                <version>3.8.5version>
            dependency>

        dependencies>
    dependencyManagement>

    <modules>
        <module>ruoyi-adminmodule>
        <module>ruoyi-frameworkmodule>
        <module>ruoyi-systemmodule>
        <module>ruoyi-quartzmodule>
        <module>ruoyi-generatormodule>
        <module>ruoyi-commonmodule>
        <module>ruoyi-emsmodule>
    modules>
    <packaging>pompackaging>


    <dependencies>

    dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <version>3.1version>
                <configuration>
                    <source>${java.version}source>
                    <target>${java.version}target>
                    <encoding>${project.build.sourceEncoding}encoding>
                configuration>
            plugin>
        plugins>
    build>

    <repositories>
        <repository>
            <id>publicid>
            <name>aliyun nexusname>
            <url>https://maven.aliyun.com/repository/publicurl>
            <releases>
                <enabled>trueenabled>
            releases>
        repository>
    repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>publicid>
            <name>aliyun nexusname>
            <url>https://maven.aliyun.com/repository/publicurl>
            <releases>
                <enabled>trueenabled>
            releases>
            <snapshots>
                <enabled>falseenabled>
            snapshots>
        pluginRepository>
    pluginRepositories>

project>

所以打包顺序也是common-system-quartz-generator-framework-ems-admin-父pom

你可能感兴趣的:(Java速成,spring,boot,后端,java,maven,intellij-idea,java-ee)