mybatis+spring boot, mapper 提示Could not autowire. No beans of … type found


工具及背景: IntelliJ IDEA 2016.1.3 Ultimate。spring boot, maven項目,利用mybatis 注解的方式查詢mysql。

業務邏輯關系:controller --> Service接口 ----> serverImpl --->Dao -->DaoImpl ---> mapper -->db

問題:mapper提示Could not autowire. No beans of … type found?如圖:

其中ProductDaoMyBatisMapper是個接口,用於查詢mysql,結構如下圖:

 

 

解決辦法:將第一張圖中的ProductDaoMyBatis類序列化,即實現Serializable 接口即可,如下圖:

 

補:pom.xml

<!--mybatis-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>

方法二: 還有一種方式,修改idea配置,將spring 的severity的值設置為"warning", 如下:


免責聲明!

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



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