idea热部署

idea spring-boot-dvtools热部署要做哪些操作和配置

1.在POM配置文件中加入依赖包

<!--热部署依赖包-->        
<!--Spring 官方提供的热部署插件 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
          <dependency>
              <groupId>com.github.pagehelper</groupId>
              <artifactId>pagehelper-spring-boot-starter</artifactId>
              <version>${pagehelper-spring-boot-starter.version}</version>
          </dependency>

2.开启热部署

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

3.开启idea自动make功能
按上面操作找不到就按图来:先File-Settings然后按图操作4. devtools的配置在application.yml中配置一下devtools

spring:
  devtools:
    restart:    
  enabled: true
#设置开启热部署    
  additional-paths: src/main/java
#重启目录      
exclude: WEB-INF/**   freemarker:   
cache: false 
  #页面不加载缓存,修改即时生效
  1. IDEA中配置当我们修改了类文件后,idea不会自动编译,得修改idea设置。

    (1)File-Settings-Compiler-Build Project automatically
    在这里插入图片描述
    (2)ctrl + shift + alt + / ,选择Registry,勾上 Compiler autoMake allow when app running
    ctrl + shift + alt + / ,选择Registry,勾上 Compiler autoMake allow when app running

6.设置项目启动加载方式
(1)菜单栏选择 Run->Edit Configurations…
在这里插入图片描述

(2)找到spring boot下的 On ‘Update’ action 和 On frame deactivation,选择 Update classes and resources
在这里插入图片描述

最后测试热部署,随便修改一个类中的代码,查看idea最下方的提示条,出现 build 后 紧接着 出现 parsing java… 表示正在重新编译,等待项目自动重新启动后就可以看见修改的类生效了
重点一定要在在配置文件application.properties 增加如下:logging.level.org.springframework.boot.autoconfigure: ERROR

spring.devtools.restart.poll-interval=2sspring.devtools.restart.quiet-period=1s
如果是配置文件格式是application.yml 那就创建一个properties格式的配置文件

7.如果报错清理一下缓存试试idea清理缓存的方法:File -> Invalidate Caches /Restart
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值