posts - 88, comments - 3, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理
项目用mvn exec:exec指令来启动server, 工作中需要调式server初始化的过程, 很容易想到mvnDebug, 但是发现设置的断点都没有hit, 反复调式多次都是如此,折腾了1个多小时, 突然看到stackoverflow 上有人说exec:exec是独立进程模式, mvnDebug的一些debug选项都被append到了父进程了. idea设置断点就然并卵了.

知道了问题所在解决就容易了, 只要修改pom.xml, 然后直接mvn exec:exec就能正常调式了
            <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>

总结就是exec:exec是要独立一个新进程来执行程序的, exec:java就相反, 其实用mvnDebug + exec:java也是理论可行的

只有注册用户登录后才能发表评论。


网站导航: