在pom.xml里配置
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.example.demo.DemoApplication</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin>
生成的包就可以在服务器上 使用命令启动:java -jar demo.jar