springboot打包排除指定jar包依赖,有两种场景
1、打war包
只需要scope配置provided就可以(红色部分)
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>
2、打jar包
jar包不能采用上面的方式,需要在springboot的plugin中排除对应的jar包(红色部分)
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!-- 如果没有该项配置devtools不会起作用,即应用不会restart --> <fork>true</fork> <!--支持静态文件热部署--> <addResources>true</addResources> <layout>ZIP</layout> <mainClass>com.Application</mainClass> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin>