spring boot+mybatis報錯mapper無法注入


搭建spring boot項目時啟動出現的問題,先來看異常片段:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-04 09:32:21.462 ERROR 18900 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
 
***************************
APPLICATION FAILED TO START
***************************
 
Description:
 
Field userMapper in com.drefore.demozw.admin.service.TestOneService required a bean of type 'com.drefore.demozw.mapper.UserMapper' that could not be found.
 
The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)
 
 
Action:
 
Consider defining a bean of type 'com.drefore.demozw.mapper.UserMapper' in your configuration.

提示mapper未找到無法注入

在網上搜索了一圈有說項目結構的問題,application入口類應該放在 mapper同級目錄下,可是我的目錄結構沒問題,可能別的地方適用,在我這只好另找辦法,最后在application入口類上添加該注解解決問題

@MapperScan("mapper文件夾路徑")


免責聲明!

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



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