2023-11-13 10:15:17
之前有写过一篇博客,内容是实现了springboot打包中的maven依赖jar包分离(详见:Springboot的jar包分离),确实能够达到预期。但是当我们新增一些依赖时,之前的配置无法便捷的获得依赖项,所以更正完善了一下配置,本文仅作留档方便后续查询。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>top.dreamcenter.bill.BillApplication(你的主启动类)</mainClass>
<layout>ZIP</layout>
<includes>
<include>
<groupId>nothing</groupId>
<artifactId>nothing</artifactId>
</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>export-jar-resource</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<type>jar</type>
<includeTypes>jar</includeTypes>
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
然后执行时,java -jar -Dloader.path=libs xxx.jar 即可