Eclipse远程连接服务器调试代码(spring boot项目)Windows服务器

Eclipse远程连接服务器调试代码(spring boot项目)

先用mvn package进行项目打包 如下图报错
Results :

Tests in error:
HotelApplicationTests.initializationError ? IllegalState Unable to find a @Spr…

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.694 s
[INFO] Finished at: 2019-10-22T09:35:47+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project ruzhuDueros: There are test failures.
[ERROR]
[ERROR] Please refer to 项目所在路径\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException在这里插入图片描述
解决办法使用命令:mvn clean package -Dmaven.test.skip=true
命令的含义:清class文件,打包构建,跳过测试
在这里插入图片描述
打包好项目放到服务器上,命令行cd到项目包目录使用以下命令
java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=端口号,suspend=y -jar 项目包.jar
(如果有frp 当前与frp.ini里设置的端口一致)
此处参数suspend的取值有两个,“y”或者“n”,如果您刚开始就想调试的话,将参数设置为”suspend=y”,这样Eclipse会远程连接Java应用程序。
如果你想先运行项目,然后连接Eclipse,那么可以将参数设置为”suspend=n”,这样的话,Java应用程序会正常运行,之后Eclipse会开始远程连接。
运行成功后
打开eclipse的Debug Configurations–>Remote Java Application
在这里插入图片描述
点击Debug进行断点调试(本地代码需要与上传到服务器的代码一致)

如果Failed to connect to remote VM. Connection refused”或者”Connection refused: connect”,那么可能出现的原因有两种可能。第一是您的Java项目没有运行在远程主机上,第二是输入端口和远程服务器地址有误
可以尝试测试与远程服务器是否连通
https://jingyan.baidu.com/article/93f9803f4a6454e0e46f55b5.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值