Mastering Spring Cloud
上QQ阅读APP看书,第一时间看更新

Developer tools

Spring Boot offers some other useful tools for developers. The really cool thing for me is that the application is automatically restarted whenever files on the project classpath change. If you use Eclipse as your IDE, the only thing you have to do to enable it is to add the spring-boot-devtools dependency to the Maven pom.xml. Then, try to change something in one of your classes and save it. The application automatically restarts, and it takes much less than stopping and starting in the standard way. When I start our sample application, it takes about 9 seconds, and automatic restart takes only 3 seconds:

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

We can exclude some resources if there is no need to trigger a restart when they are changed. By default, any file available on the classpath that points to a folder will be monitored for changes, even static assets or view templates, which do not need restarting. For example, if they are placed in the static folder, you can exclude them by adding the following property to the application.yml configuration file:

spring:
devtools:
restart:
exclude: static/**