springBoot项目打jar包问题;代码和依赖分开打包;多模块打包问题

springBoot 打包问题;代码和依赖分开打包

配置详情

默认打包方式

<!--jar包名称-->
<finalName>daima1.0</finalName>
<!--默认打包方式-->
<plugins>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <encoding>UTF-8</encoding>
    </configuration>
</plugin>
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.3.7.RELEASE</version>
    <configuration>
        <mainClass>com.example.daimademo.DaimaDemoApplication</mainClass>
    </configuration>
    <executions>
        <execution>
            <id>repackage</id>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>```

依赖分离 只打包可执行文件

<plugin>
  <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-maven-plugin</artifactId>
   <version>2.3.7.RELEASE</version>
</plugin>

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-jar-plugin</artifactId>
   <configuration>
       <archive>
           <manifest>
               <addClasspath>true</addClasspath>
               <!-- MANIFEST.MF 中 Class-Path 加入前缀 -->
               <classpathPrefix>lib/</classpathPrefix>
               <!-- jar包不包含唯一版本标识 -->
               <useUniqueVersions>false</useUniqueVersions>
               <!-- 指定入口类 -->
               <mainClass>com.example.daimademo.DaimaDemoApplication</mainClass>
           </manifest>
       </archive>
       <outputDirectory>${project.build.directory}</outputDirectory>
   </configuration>
</plugin>

<!-- 拷贝依赖 -->
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-dependency-plugin</artifactId>
   <executions>
       <execution>
           <id>copy-dependencies</id>
           <phase>package</phase>
           <goals>
               <goal>copy-dependencies</goal>
           </goals>
           <configuration>
               <outputDirectory>${project.build.directory}/lib</outputDirectory>
               <overWriteReleases>true</overWriteReleases>
               <overWriteSnapshots>true</overWriteSnapshots>
               <overWriteIfNewer>true</overWriteIfNewer>
           </configuration>
       </execution>
   </executions>
</plugin>

多模块打包问题
Maven多模块工程打包指定模块工程执行如下命令:
mvn clean package -pl 指定模块工程名 -am

参数说明:
-am --also-make 同时构建所列模块的依赖模块;
-amd -also-make-dependents 同时构建依赖于所列模块的模块;
-pl --projects 构建制定的模块,模块间用逗号分隔;
-rf -resume-from 从指定的模块恢复反应堆。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值