You just want to see an minimal example of Spring boot and how to make it auto updates files which are changed.
This page is for you.
This example is a part of Spring Boot with all examples
Full Code with Spring Boot 1.5.8.RELEASE:
What you need for run this:
- Maven 3
- Java 8
What the code will do:
- [Not the point] Call an url then the service will call a JSP file which has JSTL tag
- When you change the JSP files or static files, the Spring Boot will update the change
- When you change the java file and compile, the Spring Boot will update the change
This is the file structure:
Most of the class is the same as Spring Boot with JSP example . I will not explain it here.
You just have to add this dependency in pom.xml :
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
run this in console:
mvn clean package
Then run this to start:
mvn clean spring-boot:run
Open a browser and try to go to this url:
Then you should see this:
Try to change testjsp-view.jsp and go to the url again, you will see the change instantly.
Go to this url:
Try to change staticfile.txt and go to the url again, you will see the change instantly.
Try to change java class, for example, TestController.java. But Spring Boot will not see the change in java file, it will see the change in class file. So, you need to recompile the file. In IntelliJ, you can just shift + F9.