springboot整合mybatis的常見錯誤
阿新 • • 發佈:2018-12-26
1.Field dao in com.qftsiot.SvnCheckoutDemoApplication required a bean of type ‘com.*.dao.*Dao’ that could not be found錯誤
出現該錯誤的原因是因為mybatis沒有去掃描dao介面所在的包,我們需要在dao介面的上方新增@Mapper註釋
2.org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.*.dao.*Dao.insert錯誤
如果大家檢查了 mapper的namespace和dao介面的全名稱一致時、方法的名稱與對映的sql語句id完全一致,這時候錯誤及其可能是使用maven時不會自動將.xml檔案、
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include >
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include >
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>