1. 在目标工程中的pom.xml引入的maven-plugin工程,例如:
<plugin>
<groupId>com.github.mengweijin</groupId>
<artifactId>code-generator-maven-plugin</artifactId>
<version>latest version</version>
</plugin>
2. 在目标工程中的终端中输入命令,启用maven远程调试,执行结果如下:
$ C:\Source\code\gitee\code-generator-maven-plugin> mvndebug code-generator:mybatis
Listening for transport dt_socket at address: 8000
这时候打开了一个8000监听端口。
3. 在maven-plugin源码工程中,配置一个远程调试连接,连接到目标工程的8000端口。
4. 在maven-plugin插件源码工程中打上断点,点击debug按钮,就可以连接到目标工程的maven调试端口8000. 此时,代码运行到断点处停住,达到了调试的目的。