溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Springboot mybatis常見配置問題解決

發布時間:2020-08-30 20:05:55 來源:腳本之家 閱讀:212 作者:沒有故事的安徒生 欄目:編程語言

這篇文章主要介紹了Springboot mybatis常見配置問題解決,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下

Invalid bound statement (not found): com.example.blog.dao.DemoMapper.selectByExample"

打包的時候沒有打包 mapper.xml 文件

<resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>**/*</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </resource>

沒有掃描到 mapper.xml 文件

mybatis:
 # mapper.xml 文件路徑
 mapper-locations: classpath:com/example/blog/dao/mapper/*.xml
 # mybatis的xml文件中需要寫類的全限定名,可以配置自動掃描包路徑給類配置別名
 type-aliases-package: com.example.blog.entity

Field demoMapper in com.example.demo.service.DemoServiceImpl required a bean of type 'com.example.demo.dao.DemoMapper' that could not be found.

原因:找不到dao層的mapper文件

啟動類添加mapper掃描

@MapperScan("com.example.demo.dao")
@SpringBootApplication
public class BlogApplication {
}

添加@Mapper注解

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持億速云。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女