小编典典

Local debugging application launched on tomcat with cargo in IntelliJ

tomcat

我试图在我的货物配置中启用调试。我正在使用具有以下配置的cargo-maven2-plugin版本1.4.19。

<plugins>
  <plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.4.19</version>
    <configuration>
      <container>
        <containerId>tomcat8x</containerId>
      </container>
      <configuration>
        <type>standalone</type>
        <properties>
        <cargo.servlet.port>8080</cargo.servlet.port>
        <cargo.jvmargs>
          -Xmx2048m
          -Xms512m
          -Xdebug
          -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=63342
          -Xnoagent
          -Djava.compiler=NONE
        </cargo.jvmargs>
      </properties>
    </configuration>
    <deployer>
    </deployer>
    <deployables>
      <deployable type="war" file="target/spa.war"></deployable>
      </deployables>
    </configuration>
  </plugin>

应用程序使用此配置启动,但是IntelliJ从不连接到JVM来启用调试。如何使IntelliJ连接到JVM?


阅读 226

收藏
2020-06-16

共1个答案

小编典典

我这样固定。

<plugins>
  <plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.4.19</version>
    <configuration>
      <container>
        <containerId>tomcat8x</containerId>
      </container>
      <configuration>
        <type>standalone</type>
        <properties>
        <cargo.servlet.port>8080</cargo.servlet.port>
        <cargo.jvmargs>
          -Xmx2048m
          -Xms512m
          -Xdebug
          -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009
          -Xnoagent
          -Djava.compiler=NONE
        </cargo.jvmargs>
      </properties>
    </configuration>
    <deployer>
    </deployer>
    <deployables>
      <deployable type="war" file="target/spa.war"></deployable>
      </deployables>
    </configuration>
  </plugin>

我通过更改地址来使用另一个端口。

-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009

I then created an IntelliJ run config for a remote by going to. Run > Edit Configurations > + > Remote I configured the remote to go to localhost and
the port I had previously chosen <9009>.

完成此操作后,我可以开始运行货物,然后作为一个单独的过程启动调试器以启用调试。

如果需要,可以将suspend参数更改为no。

-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009

然后,无需运行调试器即可开始构建货物。

2020-06-16