原文地址:/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 替换为依赖包所在的目录。