原因是接口和xml映射文件没有绑定起来。
我这里出错是因为配置文件有问题。即mybatis配置缩进了。
spring:
datasource: #配置datasource
username: root
password: 123456
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql:///blog
type: com.alibaba.druid.pool.DruidDataSource #使用那个连接池
mybatis:
mapper-locations: classpath*:mapper/*Mapper.xml
其实应该不缩进,不是spring下的配置。mybatis顶格。
spring:
datasource: #配置datasource
username: root
password: 123456
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql:///blog
type: com.alibaba.druid.pool.DruidDataSource #使用那个连接池
mybatis:
mapper-locations: classpath*:mapper/*Mapper.xml
学习java的,可以关注公众号,可以免费获取毕业设计项目、各种免费软件、资料,笔记哦。