本地调试应用程序在tomcat上启动,货物在IntelliJ中

Pab*_*mer 7 java tomcat intellij-idea cargo cargo-maven2-plugin

我正在尝试在我的货物配置中启用调试.我正在使用具有以下配置的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>
Run Code Online (Sandbox Code Playgroud)

应用程序使用此配置启动,但IntelliJ从不连接到JVM以启用debuging.如何使IntelliJ连接到JVM?

Pab*_*mer 7

我这样修好了.

<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>
Run Code Online (Sandbox Code Playgroud)

我通过改变地址来使用另一个端口.

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

然后,我通过转到为远程创建了一个IntelliJ运行配置.Run > Edit Configurations > + > Remote我将远程配置为localhost和我之前选择的端口<9009>.

在此输入图像描述

执行此操作后,我可以启动货物运行,然后启动调试器作为单独的过程来启用窃听.

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

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

然后货运构建将在不运行调试器的情况下启动.