springboot项目打包jar后部署到服务器以及远程调试服务器项目

一、pom.xml中打包的配置如下(booking表示打包后文件的名字,0.0.1-SNAPSHOT表示打包文件的版本,jar表示打包文件为jar包)

	com
	booking
	0.0.1-SNAPSHOT
	jar

二、项目配置build path->configure build path->修改JRE System Library为jdk(不能jre,maven打包jar包需要jdk支持),如图:

springboot项目打包jar后部署到服务器以及远程调试服务器项目_第1张图片
springboot项目打包jar后部署到服务器以及远程调试服务器项目_第2张图片

三、pom.xml文件添加下面的代码


		
			
				org.springframework.boot
				spring-boot-maven-plugin
			
			
			  
			    maven-compiler-plugin
                  
                    1.8  
                    1.8  
                     utf8   
                  
            
            
            
				org.apache.maven.plugins
				maven-surefire-plugin
				
					true
				
			
		
	

四、选中项目右键run as->maven clean(清除上次打包的文件)

五、选中项目右键run as->maven install(将项目打包成jar包)

六、第五步执行成功后在项目的target目录下会有对应的jar包(第一次执行第五步可能会比较久)


将jar包部署到服务器

1.将jar包上传到服务器任意目录,然后cd 到该目录下执行下面的命令(其中booking-0.0.1-SNAPSHOT.jar为你要部署的jar包,booking.log为项目运行日志文件)

nohup java -jar booking-0.0.1-SNAPSHOT.jar >booking.log 2>&1 &

远程调试项目

cd到项目jar所在目录下,执行下面的命令(其中8018为监听端口,需要开放该端口才能远程调试)

java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8018,suspend=n -jar booking-0.0.1-SNAPSHOT.jar

eclipse远程调试步骤如下(当前项目代码需要跟服务器的完全一致)

点击debug那只虫子,选中debug configuration->双击remote java application

springboot项目打包jar后部署到服务器以及远程调试服务器项目_第3张图片

你可能感兴趣的:(springboot,项目部署)