【发布时间】:2026-02-19 01:20:02
【问题描述】:
我是 Spring 框架的新手,所以我从 Spring Boot 项目开始。
特别是,我采用了https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-secure-jdbc 项目并修改了 pom.xml 以使其成为自包含(在 parent->artifactId 标记中将 spring-boot-samples 替换为 spring-boot-starter-parent,删除了属性节点,从http://docs.spring.io/spring-boot/docs/1.2.2.BUILD-SNAPSHOT/reference/htmlsingle/#getting-started-maven-installation添加到repositories和pluginRepositories中)。
我首先使用“mvn spring-boot:run”在 STS 之外成功构建并运行了这个应用程序,然后将 Maven 项目导入 STS,它在那里成功构建并运行。
我可以通过右键单击项目文件夹并选择 Run->Debug As ...->Spring Boot App 来调试此应用程序,并且调试器确实会在我在 ApplicationSecurity 类方法中设置的断点处停止。但是,浏览器窗口不会在 STS 和系统浏览器中自动弹出(我期望 - 这是正确的吗?)。
当我在 STS/Eclipse 中使用“内部 Web 浏览器”浏览到 localhost(端口 8080)时,HTML 页面会呈现出来,但我在 @RequestMapping("/") 方法中设置的断点不会被命中(我怀疑这可能是由于浏览器与调试器处于单独的进程中)。
那么,我如何在 STS 中调试 @RequestMapping 方法 - 这将有助于我更好地理解 Spring 框架。
我对 Eclipse/STS 的了解有限,所以我的安装会不会有问题?
【问题讨论】:
-
你的应用有自己的main方法吗?
-
是的,我可以在发布这个问题之前对其进行调试。
标签: maven debugging spring-mvc spring-boot spring-tool-suite