簡體   English   中英

使用 exec-maven-plugin 進行調試

[英]Debugging with exec-maven-plugin

我正在使用exec-maven-plugin執行我的 java 應用程序並使用以下設置從我的 IDE (IntelliJ) 運行調試:

<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>exec-maven-plugin</artifactId>
   <version>1.4.0</version>
   <executions>
      <execution>
        <id>exec_1</id>
        <phase>deploy</phase>
        <goals>
            <goal>java</goal>
        </goals>
      </execution>
   </executions>
   <configuration>
       <mainClass>com.myapp.app</mainClass>
   </configuration>
</plugin>

而且效果很好。 然后,我更改我的設置以執行一個真實的java命令行,它將運行相同的應用程序:

<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>exec-maven-plugin</artifactId>
   <version>3.0.0</version>
   <executions>
      <execution>
        <id>exec_1</id>
        <phase>deploy</phase>
        <goals>
            <goal>exec</goal>
        </goals>
      </execution>
   </executions>
   <configuration>
      <executable>java</executable>
       <arguments>
           <argument>-cp</argument>
           <argument>
               "dir1";"dir2;etc..."
           </argument>
           <argument>com.myapp.app</argument>
       </arguments>
   </configuration>
</plugin>

它可以執行應用程序,但不會將調試器附加到 IDE。 那么,我可以添加哪些額外的參數來讓它捕獲調試中斷?

When you launch maven goal in debug mode - you are launching debug for the Maven goal process, but you need to debug the forked by the Maven goal JVM process. 為此,您可以

  • 為此進程指定遠程調試 JVM 選項,例如-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000 (請參閱SO 帖子),然后在 IDE 中啟動遠程調試配置 請參閱 IDE 中有關遠程調試的本教程
  • 使用 IDE 自己的運行/調試配置來啟動和調試應用程序。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM