使用spring-boot和IntelliJ调试jsp [英] Debugging jsp with spring-boot and IntelliJ

查看:1266
本文介绍了使用spring-boot和IntelliJ调试jsp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用spring-boot,jsp和嵌入式tomcat开发一个Web应用程序(war包装)。
应用程序运行正常,如果我使用spring-boot:run goal添加maven运行配置,我可以毫无问题地调试java文件。

I'm developing a web app (war packaging) using spring-boot, jsp and an embedded tomcat. The app runs fine and I can debug java files without any problems if I add a maven run configuration with the spring-boot:run goal.

但是当我尝试在我的一个jsp文件中添加断点IntelliJ显示此错误:'断点不属于任何类'。

But when I try to add a breakpoint in one of my jsp files IntelliJ shows this error: 'Breakpoint doesn't belong to any class'.

如果我配置IntelliJ使用外部tomcat服务器然后jsp调试工作正常。

If I configure IntelliJ to use an external tomcat server then the jsp debugging works perfectly.

有没有办法使用spring-boot maven目标调试jsp?这是spring-boot或IntelliJ中maven运行配置的问题吗?

Is there a way of debugging jsp using the spring-boot maven goal? Is this a problem with spring-boot or with maven run configurations in IntelliJ?

我真的希望能够使用我的开发环境中的完整Spring启动功能。

I'd really like to be able to use the full spring boot capabilities from my dev environment.

谢谢。

推荐答案

问题在于春季启动为该应用程序生成另一个进程。您必须告诉启动您要调试,而不是仅在调试模式下运行maven或gradle命令。 :-(
见:

The problem is that spring boot spawns another process for the app. You have to tell boot that you want to debug and not just run the command for maven or gradle in debug mode. :-( See:

  • http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-remote-debug-gradle-run
  • http://docs.spring.io/spring-boot/docs/1.1.4.BUILD-SNAPSHOT/maven-plugin/examples/run-debug.html

更新:
对于我当前的项目,我只提供一个用于在war文件中初始化spring boot的类。(请参阅相应的howtos以使用弹簧启动来部署在真正的webcontainers中的war文件)

Update: For my current project, I just provide a class to initialize spring boot in a war file. (See corresponding howtos to use spring boot for war files that are deployed in real webcontainers)

所以在开发前端的东西时我使用springboot:运行以快速重新加载资源等,并调试java代码我将这些东西部署到调试模式的tomcat中。
对于一个版本我只需要决定哪个我想要的打包类型,因为我的应用程序能够以jar或war文件的形式运行。

So during development of frontend stuff I use springboot:run to have quick reloads of resources etc. and for debugging of java code I deploy the stuff into a tomcat in debug mode. For a release I just have to decide which packaging type I want, as my app is capable of running as jar or war file.

BTW:如果你想只使用tomcat(特殊过滤器等等)你可以使用嵌入式tomcat进行springboot:运行,因此你的环境更相似,你不会搜寻鬼虫; - )

BTW: If you want to use tomcat only stuff (special filters and so on) you can use an embedded tomcat for springboot:run as well, so your environments are more similar and you don't hunt ghost bugs ;-)

更新2

根据 https://github.com/spring-projects/spring-boot/issues/1138 您可以运行启动应用程序的主要方法进行调试。我想至少使用过一次maven目标是有帮助的,所以一切都被编译/复制等等。它对我有用! : - )

According to https://github.com/spring-projects/spring-boot/issues/1138 you can just run the main method of your boot app to debug. I guess it helps to have used the maven target at least once so everything is compiled/copied etc. It works for me! :-)

更新3
根据spring boot团队的说法,他们改变了spring-boot:run的工作方式,所以从1.2开始你也应该能够使用maven目标的调试模式,虽然他们推荐的启动spring boot应用程序的方法始终是启动main方法。

Update 3 According to the spring boot team, they changed the way spring-boot:run works, so beginning with 1.2 you should be able to use the debug mode for the maven target as well, although their recommend way to start spring boot apps is always to start the main method.

更新4
我可以确认从spring 1.2开始,您可以在调试模式下直接运行maven目标,以便能够设置断点等。

Update 4 I can confirm that beginning with spring 1.2 you can directly run the maven targets in debug mode to be able to set breakpoints etc.

这篇关于使用spring-boot和IntelliJ调试jsp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆