springboot 2.6+啟動(dòng)錯(cuò)誤_循環(huán)依賴

解決升級(jí) Spring Boot 2.6后,因循環(huán)引用導(dǎo)致啟動(dòng)時(shí)報(bào)錯(cuò)的問題
Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
原因
依賴循環(huán)引用是不鼓勵(lì)的,默認(rèn)情況下是禁止的。更新應(yīng)用程序以刪除bean之間的依賴循環(huán)。作為最后的手段,可以通過設(shè)置spring.main來自動(dòng)打破循環(huán)。allow-circular-references為true。
只需要在application.properties 文件中 加入 一行代碼
spring.main.allow-circular-references=true
標(biāo)簽: