在IDEA中Spring boot配置热部署无效问题解决方式

只要在pom文件中添加下面代码段即可

 
  1. <!-- 热部署 -->

  2. <dependency>

  3. <groupId>org.springframework.boot</groupId>

  4. <artifactId>spring-boot-devtools</artifactId>

  5. <optional>true</optional>

  6. <scope>true</scope>

  7. </dependency>

  8.  
  9. <build>

  10. <plugins>

  11. <plugin>

  12. <groupId>org.springframework.boot</groupId>

  13. <artifactId>spring-boot-maven-plugin</artifactId>

  14. <configuration>

  15. <!-- 没有该配置,devtools 不生效 -->

  16. <fork>true</fork>

  17. <addResources>true</addResources>

  18. </configuration>

  19. </plugin>

  20. </plugins>

  21. </build>

这样配置在myeclipse中已经可以实现热启动,但是在idea中配置好无效,下面需要修改idea中的两个配置

  1. setting –> compiler ,将 Build project automatically 勾选上
  2. alt + shift + a (我的是ctrl+alt+shfit+/)搜索 registry 选第一个,弹出框后下拉找到compiler.automake.allow.when.app.running 勾选上即可。

热部署无效问题已解决。

以上是搜索出来的解决方法,并无法解决。每次改完代码,用ctrl+F9,可以更新,但只能更新后台部分,前台部分暂未得到解决。明明classes里的编译文件,全都更新了的= = 不知道为嘛前台页面在浏览器中就是不更新= =,已排除浏览器缓存原因

补充:application.properties中加入spring.thymeleaf.cache = false,每次改完代码ctrl+F9,前后台都会更新啦!!!

猜你喜欢

转载自my.oschina.net/u/2364025/blog/1850719