John Warde
John Warde

Reputation: 355

How to debug a Spring Boot Web Application in STS?

I am new to the Spring Framework and so I started with the Spring Boot projects.

In particular, I took the https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-secure-jdbc project and modified the pom.xml so that it becomes self contained (replaced spring-boot-samples with spring-boot-starter-parent in the parent->artifactId tag, removed properties node, added in repositories and pluginRepositories from http://docs.spring.io/spring-boot/docs/1.2.2.BUILD-SNAPSHOT/reference/htmlsingle/#getting-started-maven-installation).

I successfully built and ran this application outside of STS first with 'mvn spring-boot:run', then imported the Maven project into STS and it builds and runs there successfully.

I am able debug this application by right-clicking on the project folder and choosing Run->Debug As ...->Spring Boot App and the debugger does stop at the breakpoints I've set in the ApplicationSecurity class methods. However, the browser window does not automatically pop-up in STS nor the system browser (which I expect - is this correct?).

When I browse to localhost (port 8080) using the 'Internal Web Browser' within STS/Eclipse the HTML pages render out but the breakpoints that I've set in the @RequestMapping("/") methods do not get hit (I suspect that this is probably due to the fact that the browser is in a separate process to the debugger).

So, how do I debug @RequestMapping methods within STS - this would help me to understand the Spring framework better.

I have limited knowledge of Eclipse/STS, so could there be a problem with my installation?

Upvotes: 1

Views: 5788

Answers (1)

Dave Syer
Dave Syer

Reputation: 58094

You don't need to use the embedded browser to debug a server (the browser is a separate process). If your @RequestMapping breakpoints are not hit then I suspect Spring didn't dispatch to those routes for whatever reason (maybe security?).

Upvotes: 1

Related Questions