1.打包时不包含依赖jar,在pom.xml中增加以下依赖
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includes>
<!-- 设置没有jar包,需要的话就注释掉-->
<include>
<groupId>nothing</groupId>
<artifactId>nothing</artifactId>
</include>
</includes>
</configuration>
</plugin>
2.打包时将依赖包放到固定路径,在pom.xml中增加:
<!-- 拷贝依赖的jar包到lib目录 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- ${project.build.directory}是maven变量,内置的,表示target目录,如果不写,将在跟目录下创建/lib -->
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<!-- excludeTransitive:是否不包含间接依赖包,比如我们依赖A,但是A又依赖了B,我们是否也要把B打进去 默认不打-->
<excludeTransitive>false</excludeTransitive>
<!-- 复制的jar文件去掉版本信息 true去掉 false 不去-->
<stripVersion>false</stripVersion>
</configuration>
</execution>
</executions>
</plugin>