Spring Boot 热部署

1、pom.xml文件增加

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

2、在pom.xml里增加插件

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

3、修改idea里的选项

打开idea ,File->Settings-> Build-Execution-Deployment -> Compiler,勾选 Build Project Automatically. 

4d492fcbda999da315a1d380ed8337b6555.jpg

 

4、mac按shift+command+/ 

将看到弹窗 Enter Action or option name,输入"registry",双击第一项"Registry..." ,会弹出另一个窗口,寻找< compiler.automake.allow.when.app.running> 选中,参考如图:

fb483e15ca46ac5709cfeb7667e43e5c05a.jpg

77510bd7ac3c07e34770ed96911b69bd762.jpg

5、项目 Update选择Update Classes and resource

0395801e87939cbe46077ac7f9ca2e62314.jpg

6、热部署注意事项

(1)如果使用模板引擎,关闭缓存

在application.properties中添加

#禁止thymeleaf缓存(建议:开发环境设置为false,生成环境设置为true)

spring.thymeleaf.cache=false

(2)开启热部署后,session每次都会重置的

转载于:https://my.oschina.net/u/3777515/blog/3079563

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值