In a Spring Boot application, if you make change in your code, is it possible to see them without restarting the server? If yes, how can that be achieved?
Add spring-boot-devtools module to your project, which includes LiveReload server which can be used to trigger a browser refresh whenever a resource has been changed.You can download browser extensions from livereload.com.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
You only need to add spring-boot-devtools
dependency in your pom.xml
and yml file property:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
# for not restarting the server every time
spring.devtools.restart.enabled: false
See the Spring Boot Developer Tools.
Notice:
When you change your Java code, the server need to be restarted. The Spring Boot Developer Toolsjust help you to reload it
If it is jsp, then you do not have to restart server.
I'm using intellij, the follow dependency setting works for me.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
Try the following steps and it should work
Add the following to pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
In application.properties
spring.devtools.restart.enabled=true
Note : Ensure spring boot is restarted once after making changes to the application.properties file.
For additional information please check https://docs.spring.io/spring-boot/docs/1.5.16.RELEASE/reference/html/using-boot-devtools.html
Just enable Build Automatically in the Project tab in STS, if you have the dependency in your pom.xml
© 2022 - 2024 — McMap. All rights reserved.