码迷,mamicode.com
首页 > 编程语言 > 详细

SpringBoot(4) SpringBoot热部署

时间:2018-10-12 17:03:45      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:工具   snap   应用   depend   build   resource   spring   div   软件   

热部署,就是在应用正在运行的时候升级软件,却不需要重新启动应用。

使用springboot结合dev-tool工具,快速加载启动应用

官方地址:https://docs.spring.io/spring-boot/docs/2.1.0.BUILD-SNAPSHOT/reference/htmlsingle/#using-boot-devtools
核心依赖包:
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-devtools</artifactId>
  <optional>true</optional>
</dependency>
添加依赖后,在ide里面重启应用,后续修改后马上可以生效。

pom文件中修改:

 1 <dependencies>
 2     <dependency>
 3         <groupId>org.springframework.boot</groupId>
 4         <artifactId>spring-boot-starter-web</artifactId>
 5     </dependency>    
 6         
 7     <dependency>
 8         <groupId>org.springframework.boot</groupId>
 9         <artifactId>spring-boot-devtools</artifactId>
10         <optional>true</optional>
11     </dependency>
12 </dependencies>
13 
14 
15 <build>
16   <plugins>
17     <plugin>
18       <groupId>org.springframework.boot</groupId>
19           <artifactId>spring-boot-maven-plugin</artifactId>
20        </plugin>
21     </plugins>
22 </build>

不被热部署的文件
  1、/META-INF/maven, /META-INF/resources, /resources, /static, /public, or /templates
  2、指定文件不进行热部署 spring.devtools.restart.exclude=static/**,public/**
  3、手工触发重启(改代码不重启,通过一个文本去控制) spring.devtools.restart.trigger-file=trigger.txt

在application.properties文件中添加

#指定某些文件不进行监听,即不会进行热加载
#spring.devtools.restart.exclude=application.properties

#通过触发器,去控制什么时候进行热加载部署新的文件
spring.devtools.restart.trigger-file=trigger.txt

 

SpringBoot(4) SpringBoot热部署

标签:工具   snap   应用   depend   build   resource   spring   div   软件   

原文地址:https://www.cnblogs.com/platycoden/p/9778946.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!