1. 添加打包插件依赖并且配置主类,如果引入外部jar包,一定要加<includeSystemScope>true</includeSystemScope>
    Springboot+maven打jar包在服务器运行
	<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>
  1. 项目右键run as–>maven install,控制台出现BUILD SUCCESS即为成功
    Springboot+maven打jar包在服务器运行
  2. 成功后,刷新target目录,将jar包复制到服务器
    Springboot+maven打jar包在服务器运行
  3. java -jar xxx.jar运行jar包
    Springboot+maven打jar包在服务器运行
    成功!

相关文章: