Springboot的依赖包分离
2023-11-13 10:15:17 浏览: 1275次
AI评分: 82
原因: The article provides a concise and practical configuration for Spring Boot dependency separation via Maven plugins, with a clear code example and runtime command. However, it lacks contextual explanation, motivation for the separation, and discussion of potential issues, limiting its educational value beyond simple archiving reference.
之前有写过一篇博客,内容是实现了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 即可
#springboot⚛ ❀ 评
论 ❀ ⚛

夏日博客2023-11-14 18:45:05这配置文件可以留档,下次再使用的时候就方便多了。
回复

时光潜流2023-11-15 15:08:25@夏日博客 对的,方便下次查询\( ̄︶ ̄*\))
回复