官网教程: https://github.com/dsyer/spring-boot-thin-launcher
原理; 将lib依赖全部分离出去
1 pom文件添加
<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><dependencies><dependency><groupId>org.springframework.boot.experimental</groupId><artifactId>spring-boot-thin-layout</artifactId><version>1.0.25.RELEASE</version></dependency></dependencies></plugin>
2 正常打包即可,可以看到jar文件已经非常小了,因为排除了所有的lib依赖
3 启动
java -jar -Dthin.root=. -Dthin.dryrun=true -Dthin.repo=https://xxx/repository/maven/ xxx.jar
#-Dthin.root :指定repository仓库路径
#-Dthin.dryrun:是否空运行,预热
#-Dthin.repo :指定repostory 下载的地址
