我有一个 Spring Boot 应用程序,可以在 Intellij IDE 上正常运行。即我启动了具有委托(delegate)给 SpringApplication.run 的 main 方法的 Application 类。除了热插拔之外,一切都很好。当我更改源时,我被迫重新启动应用程序。即使我在 Debug模式下启动应用程序,我也看不到热插拔工作。我可以看到 Intellij 的调试设置已启用热插拔。
我的观察表明,当我运行 springboot 应用程序时,使用的类路径是我的
/projects/MyProject/classes/production/....
当我更改代码时,classes/product
下的文件没有得到更新。 Intellij IDE 编译文件但不更新类/生产目录。如何让热插拔与适用于 spring-boot 的 IntelliJ IDE 一起使用?
最佳答案
使用 devTools 的解决方案有效:
1 - 将开发工具添加到您的项目
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
2 - 启用自动构建
打开设置 --> 构建-执行-部署 --> 编译器并启用:
Build Project Automatically.
3 - 更新compiler.automake.allow.when.app.running的值
按ctrl+shift+A
并搜索注册表
。在注册表中,启用:
compiler.automake.allow.when.app.running
<小时/>
引用文献:
关于intellij-idea - Spring Boot 与 Intellij IDE 的热插拔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23155244/