maven项目代码和jar包分开打包

引言

代码包和依赖包分开打包这样的好处是:如果只修改了逻辑代码,没有修改依赖,就只需要更新代码包即可。
在pom.xml中下中做如下修改:

步骤1

<project>节点中修改

<packaging>war</packaging>改成<packaging>jar</packaging>

步骤2

<build>下<plugins>节点中注释掉

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

步骤3

<build>下<plugins>节点中添加如下配置:

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-dependency-plugin</artifactId>
	<executions>
	 <execution>
	     <id>copy-installed</id>
	     <phase>package</phase>
	     <goals>
	         <goal>copy</goal>
	     </goals>
	     <configuration>
	         <artifactItems>
	             <artifactItem>
	                 <groupId>${project.groupId}</groupId>
	                 <artifactId>${project.artifactId}</artifactId>
	                 <version>${project.version}</version>
	                 <type>${project.packaging}</type>
	             </artifactItem>
	         </artifactItems>
	         <outputDirectory>target/lib</outputDirectory>
	     </configuration>
	 </execution>
	 <execution>
	     <id>copy-lib</id>
	     <phase>prepare-package</phase>
	     <goals>
	         <goal>copy-dependencies</goal>
	     </goals>
	     <configuration>
	         <outputDirectory>${project.build.directory}/lib</outputDirectory>
	         <overWriteReleases>false</overWriteReleases>
	         <overWriteSnapshots>false</overWriteSnapshots>
	         <overWriteIfNewer>true</overWriteIfNewer>
	         <includeScope>compile</includeScope>
	     </configuration>
	 </execution>
	</executions>
</plugin>

效果图

在这里插入图片描述

参考: https://www.cnblogs.com/lishan1/p/10317488.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值