Appearance
IDEA 2022.3.3 修改代码后自动加载/热部署设置
1. 在 pom.xml 里添加依赖
添加开发者工具依赖
xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
添加 maven 插件
xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
2. 编译选项里勾选 Build project automatically
3. 高级设置里勾选 Allow auto-make to start even if developed application is currently running
4. 重启 idea, 启动项目,日志出现 restartedMain
表示成功
console
2023-05-27 16:42:01.693 INFO 2240 --- [ restartedMain] com.ducms.Main : Starting Main using Java 1.8.0_202 on xtcz with PID 2240 (E:\ducms-demo\spring-boot\target\classes started by Administrator in E:\ducms-demo\spring-framework)
2023-05-27 16:42:01.694 INFO 2240 --- [ restartedMain] com.ducms.Main : No active profile set, falling back to 1 default profile: "default"
2023-05-27 16:42:01.721 INFO 2240 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-05-27 16:42:01.722 INFO 2240 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-05-27 16:42:02.249 INFO 2240 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-05-27 16:42:02.255 INFO 2240 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]