【问题标题】:Local debugging application launched on tomcat with cargo in IntelliJ在 IntelliJ 中使用货物在 tomcat 上启动的本地调试应用程序
【发布时间】:2016-07-26 13:24:01
【问题描述】:

我正在尝试在货物配置中启用调试。我正在使用 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?

【问题讨论】:

    标签: java tomcat intellij-idea cargo cargo-maven2-plugin


    【解决方案1】:

    对于 gradle 4.3.0,在 json 路径 cargo&gt;local 下添加以下参数,

    jvmArgs = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000

    并开始使用应用程序,

    ./gradlew cargoRunLocal

    【讨论】:

      【解决方案2】:

      我是这样解决的。

      <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

      然后,我通过访问为遥控器创建了一个 IntelliJ 运行配置。 Run &gt; Edit Configurations &gt; + &gt; Remote我将远程配置为转到本地主机和我之前选择的端口。

      完成此操作后,我可以启动 cargo run,然后将调试器作为一个单独的进程启动以启用 bug。

      如果你愿意,你可以像这样将挂起参数更改为 no。

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

      然后货物构建将在不运行调试器的情况下开始。

      【讨论】:

      • 您是否曾经能够在不将 intellij 作为远程进程附加的情况下运行它?换句话说,您是否曾经能够一键运行并让一切正常运行?
      猜你喜欢
      • 2017-05-17
      • 1970-01-01
      • 2016-09-22
      • 2021-11-19
      • 2013-05-14
      • 1970-01-01
      • 2020-03-20
      • 2022-08-19
      • 2020-03-10
      相关资源
      最近更新 更多