Posted on 2015-10-21 17:12
Milo的海域 閱讀(832)
評論(0) 編輯 收藏 所屬分類:
Java
項(xiàng)目用mvn exec:exec指令來啟動(dòng)server, 工作中需要調(diào)式server初始化的過程, 很容易想到mvnDebug, 但是發(fā)現(xiàn)設(shè)置的斷點(diǎn)都沒有hit, 反復(fù)調(diào)式多次都是如此,折騰了1個(gè)多小時(shí), 突然看到stackoverflow 上有人說exec:exec是獨(dú)立進(jìn)程模式, mvnDebug的一些debug選項(xiàng)都被append到了父進(jìn)程了. idea設(shè)置斷點(diǎn)就然并卵了.
知道了問題所在解決就容易了, 只要修改pom.xml, 然后直接mvn exec:exec就能正常調(diào)式了
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${mvnexec.version}</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<includeProjectDependencies>true</includeProjectDependencies>
<executable>java</executable>
<workingDirectory>${basedir}/config/sim</workingDirectory>
<classpathScope>runtime</classpathScope>
<arguments>
<argument>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=4000</argument>
<argument>-classpath</argument>
<classpath/>
<argument>com.ymiao.Main</argument>
<argument>server</argument>
<argument>${basedir}/config/sim/sim.yml</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
總結(jié)就是exec:exec是要獨(dú)立一個(gè)新進(jìn)程來執(zhí)行程序的, exec:java就相反, 其實(shí)用mvnDebug + exec:java也是理論可行的