由于 IDEA Community 版本不支持配置 Tomcat、Jetty 之类的 Web Server,所以使用此版本的 IDEA 要借助插件来进行 Spring Web MVC 应用的开发。之前有使用过 tomcat7-maven-plugin,所以在使用 Gradle 和 Jetty 的时候就去搜索是否有类似的插件,然后就找到了 Gretty 。
下面就是我整理的 Gretty 插件的配置文件 gretty.plugin ,支持 Debug:
然后在你的 web 应用的 build.gradle 中添加如下内容:
|
|
|
|
现在你就可以使用 gradle appRunWar 来运行 Web 应用了。如果在 IDEA 中配置了 Tasks 为 appRunWar 的 Run Configurations ,那么直接点击 IDEA 中的 debug 按钮就可以进行 debug 了。
参考
1、http://akhikhl.github.io/gretty-doc/Getting-started.html
2、https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000186970-How-to-Debug-webb-app-started-with-gradle-gretty