springboot应用瘦身

1、将依赖的jar包存放到其他路径

mvn dependency:copy-dependencies -DoutputDirectory=lib_path -DincludeScope=runtime

2、在pom文件添加插件属性属性

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <mainClass>com.jiawa.blog.config.BlogApplication</mainClass>
        <layout>ZIP</layout>
        <includes>
            <include>
                <groupId>nothing</groupId>
                <artifactId>nothing</artifactId>
            </include>
        </includes>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

3、运行应用jar包

java -Dloader.path=lib_path -jar target/xxx.jar

posted @ 2023-03-24 13:40  秋水秋色  阅读(34)  评论(0编辑  收藏  举报