引言
代碼包和依賴包分開打包這樣的好處是:如果只修改了邏輯代碼,沒有修改依賴,就只需要更新代碼包即可。
在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