IntelliJ IDEA 如何开启热更新修改代码自动重启springboot
网友回复
使用 spring-boot-devtools来进行热部署
1、pom.xml文件加入以下依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <!-- 这个需要为 true 热部署才有效 --> </dependency>2、在application.properties增加以下配置项
#添加那个目录的文件需要restart spring.devtools.restart.additional-paths=src/main/java #排除那个目录的文件不需要restart spring.devtools.restart.exclude=static/**,public/**3、打开IntelliJ IDEA的设置窗口,切换到compiler上,勾选自动编译项
好了,这个时候就完成了自动编译部署了。
漏了一条,还要在pom.xml中增加spring-boot-maven-plugin
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> </configuration> </plugin> </plugins> </build>