使用mvnDebug命令在maven中进行调试 [英] Debugging in maven with mvnDebug command

查看:2614
本文介绍了使用mvnDebug命令在maven中进行调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到这个:
在Maven中调试?

我正在运行intellij远程调试和maven用于我正在尝试调试的服务。

I'm running intellij remote debug and maven for a service I'm trying to debug.

我正在运行

mvnDebug tomcat7:run 

这给了我以下结果

Preparing to Execute Maven in Debug Mode
Listening for transport dt_socket at address: 8000
^Ctai-m:sb-api-internal-server tai$ m

我的问题是我想轻松更改端口。我知道我可以进入pom.xml文件并进行更改,或者我可以执行以下操作:

My problem is that I want to change the port easily. I know that I can go into the pom.xml file and change it or that I can do the following in:

mvnDebug.bat

mvnDebug.bat

@REM set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

但我希望能够在命令行上指定我的端口。有没有办法做到这一点?我希望能够在一次运行的不同地址上调试多个服务,并且我觉得必须为每个地址设置和重置调试文件设置会很麻烦。

but I want to be able to specify my port on the command line. Is there any way to do this? I want to be able to debug multiple services on different addresses running at once and am under the impression that it would be a hassle to have to set and reset the debug file setting for each one.

一位朋友说这应该是可能的,但我似乎无法找到解决方案。

A friend said it should be possible but I can't seem to find a solution.

基本上我正在寻找一种轻松切换端口的方法希望在我启动多个服务时多次修改文件时运行服务。否则你能解决另一种解决方案吗?例如,第一个调试实例在一个端口上运行,然后第二个调试实例在另一个端口上运行(硬编码)?

Essentially Im looking for a way to easily switch the port a service is running on hopefully without modifying a file multiple times as I launch multiple services. Otherwise Is there another solution you can thing of? Ex having the first debug instance running on one port and then having the second on another (hard coded)?

谢谢

推荐答案

哇,Maven让这很困难。在 MAVEN_OPTS 中设置 -Xrunjdwp 将无效,因为 mvnDebug.bat 之后添加自己的,它将覆盖 MAVEN_OPTS 。我会将 mvnDebug.bat 复制到 myMvnDebug.bat 并注释掉行MAVEN_DEBUG_OPTS = -Xdebug -Xrunjdwp:transport = dt_socket,server = y,suspend = y,address = 8000 。这样你就可以在运行之前在命令行上设置 MAVEN_DEBUG_OPT

Wow, Maven makes this difficult. Setting -Xrunjdwp in MAVEN_OPTS won't work, because mvnDebug.bat adds its own afterward, which will override MAVEN_OPTS. I would copy mvnDebug.bat to myMvnDebug.bat and comment out the line set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000. That way you can set MAVEN_DEBUG_OPT on the command line before running it.

C:\somewhere>set MAVEN_DEBUG_OPT=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8001
C:\somewhere>myMvnDebug.bat

这篇关于使用mvnDebug命令在maven中进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆