spring-boot with heat Deployment devtools

If you do not use devtools, any changes we kind of need to restart the service in order to see the effect, which is not very messed up, and now introduce the method to achieve if a hot deployment

The first step: first import dependence

1: pom.xml increase

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

2: pom.xml, add the following plug-ins

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <fork>true</fork>
    </configuration>
</plugin>

Step Two: Write application.properties

#关闭缓存,即时刷新
#spring。freemarker。cache=false
#下面这是开启及时刷新
spring.thymeleaf.cache=true
#热部署生效
spring.devtools.restart.enabled=true

#设置重启的目录,添加那个目录的文件需要restart
spring.devtools.restart.additional-paths=src/main/java
#为mybatis设置,生产环境可删除
#restart。include。mapper=/mapper-[\\w-\\.]+jar
#restart.include.pagehlper=/pagehelper-[\\w-\\.]+jar

#排除哪个目录下的文件不需要restart
#spring.devtools.restart.exclude=static/**,public/**

#classpath目录下的WEB-INF文件夹内容修改不重启
#spring.devtools.restart.exclude=WEB-INF/**

**

The third step: change the idea of ​​setting

**
When we modified the java class, IDEA default is not automatically compiled and spring-boot-devtools will change again to restart the application file in the classpath monitoring occurs,
we need to set the automatic compilation IDEA:
(1) File Compiler-the Build the Project--settings Automatically
(2) Shift + Ctrl + Alt + /, four key while pressing the
select Registry, hook Compiler autoMake allow when app running

**

So hot deployment will take effect

**

Published 33 original articles · won praise 0 · Views 848

Guess you like

Origin blog.csdn.net/ninth_spring/article/details/104714028