1.在pom.xml中加入maven-shade-plugin插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version> 1.7.1</version>
<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.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.demo.controller.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
2.在工程根目录下 win+shift+右击,打开命令行窗口,输入命令mvn install。
3.在target里生成jar。
4.命令行窗口 输入命令 java -jar xxx.jar。