在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更加龐大了, 但可以不用重啟工程還是挺方便的。