SpringBoot项目集成maven-shade-plugin

因为项目是基于springboot搭建的,按springboot的教程,打包只需要在pom添加以下即可:

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

但需要用到maven-shade-plugin插件打包,在maven-shade-plugin的dependencies添加spring-boot-maven-plugin即可,集成如下:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>
</dependencies>
<configuration>
<keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
<resource>META-INF/spring.factories</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.xxx.App</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>

版权声明:著作权归作者所有。

相关推荐

Maven添加Sonar插件配置

在 Maven 本地库中的 settings.xml 配置文件中的节点中添加如下配置(也可以配在pom.xml里):添加以下profile<profiles> <profile> <id>sonar</id> <activation> <activeByDefault>true</

Maven设置项目JDK版本为1.8

导入一个项目到iDEAL,项目中使用到lambda表达式的地方都报错,提示jdk版本不对。想到的第一种解决方案就是修改iDEAL的配置,修改两处的设置,如下:File → Settings → Java Compiler → Target bytecode version 改为1.8File → Project Structure → Modules → Language level 改为 8-L

vue-cli 3.0集成sass/scss到vue项目

尝鲜使用vue-cli 3.0.0-beta.6,很容易就可以完成scss到vue项目中。vue-cli 3提供了两种方式集成sass/scss:创建项目是选择预处理器sass手动安装sass-loader创建项目选择预处理器sass$ vue create vuedemo? Please pick a preset: (Use arrow keys)> default (babel, es

Maven添加本地Jar包到项目依赖

有两种方式添加本地的Jar包到项目里。方法一安装本地Jar到本地Maven仓库mvn install:install-file    -Dfile=/path/mylib.jar    -DgroupId=mygroup    -DartifactId=mylib    

SpringBoot入门示例

创建Maven POM文件在pom.xml添加内容如下:<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="ht