- 添加打包插件依赖并且配置主类,如果引入外部jar包,一定要加
<includeSystemScope>true</includeSystemScope>
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/5476c5ab828ba951e2eef70798eee758.png)
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!-- 引入外部jar包 一定要写下面的这句话,否则报错-->
<includeSystemScope>true</includeSystemScope>
<!-- 工程主入口 -->
<mainClass>com.jiuqi.gmc.mobile.Application</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
- 项目右键run as–>maven install,控制台出现BUILD SUCCESS即为成功
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/b475d7cdc5b43278476df41ce91eb522.png)
- 成功后,刷新target目录,将jar包复制到服务器
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/b78f85f629403c576632e8250ca0549a.png)
- java -jar xxx.jar运行jar包
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/2a296e5f3f204d401a74c0c694dd94d6.png)
成功!