Background:

During the development of a Spring Boot + Jsp project using IDEA (although JSPS are a little outdated now), there is a debug failure problem, which means that the breakpoint is not effective and cannot be entered.

Since the web page uses Jsp, Spring Boot does not support Jsp as a view by default, so directly using the Application to start the project, there will be a problem of accessing Jsp page 404, then you can use Spring Boot plug-in to start the project. This is equivalent to running the MVN spring-boot:run command

Starting the Spring Boot project in this way gives you access to the Jsp page. But if you start the project with a Debug plugin, you can see if hot deployment is a problem if the break point doesn’t work.

Premise: The project uses Jsp and the project is launched by a plug-in

The reason:

1. If your project meets the above conditions and uses a devTools hot deployment that introduces the dependency in the POM file, then the debug plug-in starts the project, the breakpoint will fail, and the dependency will be removed.

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-devtools</artifactId>
   <optional>true</optional>
</dependency>
Copy the code

<fork>true</fork> (related to DevTools) is added to the <plugin> tag in the POM file. The debug plug-in starts the project and the breakpoint will fail. Change to false and the problem is resolved.

<configuration>
    <fork>true</fork>
    <! -- spring-boot:run -->
    <jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
</configuration>
Copy the code

Fork tag: Marking dependencies as optional is a best practice (official documentation) that prevents DevTools from using your project to pass them to other modules, and it doesn’t really mean anything

3. If your POM file has both a hot deployment dependency and a fork tag, and

true
, just change true to false and the debug plug-in will start the project and the hot deployment will fail. 六四事件

Conclusion:

If your Spring Boot project uses Jsp views and starts as a plug-in, you will not be able to use debug using DevTools hot deployment, and debug will not be able to use DevTools hot deployment. Using both in this context requires additional configuration, which you can see in this blog postDebug Debug Spring Boot project configuration step (plug-in startup)

 

Supplement:

This will happen if your view is using.jsp, but not if your view is using.html, because when your view is an.html file, you can launch it directly with Application. Do some configuration for Spring Boot + Jsp reference online tutorial, start with Application, these conflicts will not occur.