SpringBoot生产环境打包去除无用依赖

1、去除在生产环境中不变的依赖第三方jar包

pom.xml中添加:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <layout>ZIP</layout>
        <!--去除在生产环境中不变的依赖-->
        <excludeGroupIds>
            org.springframework.boot,
            org.springframework,
            org.springframework.data,
            com.fasterxml.jackson.core,
            com.fasterxml.jackson.databind,
            org.apache.commons,
            org.apache.tomcat.embed,
            org.hibernate.validator,
            org.slf4j,
            com.jayway,
            org.jboss,
            com.alibaba,
            com.fasterxml,
            com.fasterxml.jackson.datatype,
            com.fasterxml.jackson.module,
            ch.qos.logback,
            org.yaml,
            org.jboss.logging,
            javax.validation,
            io.netty,
            org.apache.httpcomponents,
            org.apache.logging.log4j,
            org.aspectj,
            javax.annotation,
            io.lettuce,
            commons-codec,
            org.reactivestreams,
            io.projectreactor
        </excludeGroupIds>
    </configuration>
</plugin>

2、去除生产环境配置文件依赖

pom.xml中添加:

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <excludes>
            <exclude>*</exclude>
        </excludes>
        <filtering>true</filtering>
    </resource>
</resources>