开发中,每次对类的修改,都须要重启服务,很浪费时间,影响效率spring
。因此就须要用到热部署,节省时间提升效率。缓存
<!--Spring Boot提供了一个名为spring-boot-devtools的模块来使应用支持热部署,提升开发者的开发效率,无需手动重启Spring Boot应用--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <!-- optional=true,依赖不会往下传递,若是有项目依赖本项目,而且想要使用devtools,须要从新引入 --> <optional>true</optional> </dependency>
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <!--自动启动--> <configuration> <!--fork:若是没有该项配置,整个devtools不会起做用--> <fork>true</fork> </configuration> </plugin> <!--自定义配置spring Boot使用的JDK版本--> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>
debug: true spring: devtools: remote: restart: enabled: true #设置开启热部署 freemarker: cache: false #页面不加载缓存,修改及时生效
若是是Eclipse,配置到这里,只要重启服务,热部署就会生效了。app
可是IDEA的话,热部署还不会生效,由于devTools只会在类路径上的文件发生更改时才会自动重启,而IDEA默认不会自动编译。maven
1)File -> Settings -> Compliler,勾选Build Project automaticallyspring-boot
2)按快捷键Ctrl+Shift+Alt+/,选择1.Registryui
3)勾选compiler.automake.allow.when.app.running便可插件