700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 使用Spring Boot Thin Launcher 打包Spring Boot项目 jar包瘦身

使用Spring Boot Thin Launcher 打包Spring Boot项目 jar包瘦身

时间:2024-08-17 00:45:44

相关推荐

使用Spring Boot Thin Launcher 打包Spring Boot项目 jar包瘦身

原文地址:/p/3fa4039d90d7

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

该工具的GitHub地址为:/dsyer/spring-boot-thin-launcher

<plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><dependencies><dependency><!-- 加入该配置,使用maven package,依赖jar不会打包在项目最终jar文件内 --><groupId>org.springframework.boot.experimental</groupId><artifactId>spring-boot-thin-layout</artifactId><version>1.0.12.RELEASE</version></dependency></dependencies></plugin><!-- 加入该配置,maven package执行时会在target目录整理好依赖包 --><plugin><groupId>org.springframework.boot.experimental</groupId><artifactId>spring-boot-thin-maven-plugin</artifactId><version>1.0.12.RELEASE</version><executions><execution><!-- Download the dependencies at build time --><id>resolve</id><goals><goal>resolve</goal></goals><inherited>false</inherited></execution></executions></plugin></plugins>

整理好的依赖包所在的目录为target/thin/root/repository

我们仍然可以使用java -jar 命令启动项目。

如果启动时需要指定依赖包的目录,可以使用如下命令:

java -Dthin.root=path/to/lib -jar spring-boot-app.jar

将path/to/lib 替换为依赖包所在的目录。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。