Assume I have a controller:
1 2 3 4 5 6 7 8 9 10 11 12 13 | package albert.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { @RequestMapping("/") public String sayHello(){ return "Hello! Spring Boot!"; } } |
After I start up spring boot application, then connect to http://localhost:8080/.
The page will look like:
If I would to change some wording in the sayHello() method, and I hope it takes effect immediately.
How to fulfill this requirement?
Solution
Add spring-boot-devtools dependency in pom.xml
1 2 3 4 | <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency> |
Update application.yml, and set spring.devtools.restart.enabled=true
1 2 3 4 | spring: devtools: restart: enabled: true |
When you set this property, immediately it takes effect and you need not manually stop and start the spring boot application.
Reference
[1] http://javabeat.net/spring-boot-devtools/
No comments:
Post a Comment