在IDEA里添加了一个热部署依赖spring-boot-devtools后, 启动项目报错 java.lang.NoSuchFieldException: findAnnotationCache
网上说是缺失字段导致, 具体暂时还不知道是缺失什么字段, 但我的case非常确定是添加了热部署后报出这种启动错误。
只好照着搜索结果将所有设置走了一遍,
1, pom中添加依赖
<!--热部署--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <version>2.2.5.RELEASE</version> <optional>true</optional> </dependency>
2, 菜单栏File---Settings---Build, Execution, Deployment展开---Compiler---勾选"Build project automatically" (eclipse貌似默认这个是开着的)
3, 菜单栏Run---Edit Configurations---找到你的工程, 将On 'Update' action和On frame deactivation的下拉框都选中为Update classes and resources
4, 按快捷键Shift+Ctrl+Alt+/ 调出Registry, 勾选compiler.automake.allow.when.app.running (有点费眼力, 慢慢找) 。
然后就可以愉快地热部署了, 发现本身很吃内存的IDEA更加庞大了, 但可以不用重启工程还是挺方便的。