Spring Boot Autowirted注入找不到Bean對象解決方法


報錯:Consider defining a bean of type 'xxxxxxxxxxxxx' in your configuration

1. 你應該在 ApplyApplication 啟動類里,掃描你的 Service包,多包掃描方法如下

@SpringBootApplication(scanBasePackages = {"xx.xxx.apply.controller", "xx.xxx.apply.service.*", 
        "xx.xxx.apply.security.*"})

2. 你還需要在你的Service的實現類,注意!是實現類里添加注解 @service

3. 這個時候基本上就可以實現自動裝配了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM