Invalid bound statement (not found)--spring boot集成mybatis

问题:

{"timestamp":"2019-07-02T10:21:32.379+0000","status":500,"error":"Internal Server Error","message":"Invalid bound statement (not found): com.example.mybatistest.mapper.ISelectIdMapper.selectId","path":"/queryIdByName"}

解决:

1.appliation.yml中要加上xml配置,我就是这个问题

mybatis:
  configuration:
    #    map-underscore-to-camel-case: true
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  mapper-locations: classpath:mappers/*.xml

2.xml中namespace中配置的mapper一定要正确,我的是com.exa前引号后多了一个空格,让我找了两天才找出来。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.mybatistest.mapper.ISelectIdMapper">
<select id="selectId" resultType="String">
    select id from t_user where name=#{name}
</select>
</mapper>

猜你喜欢

转载自www.cnblogs.com/pu20065226/p/11122369.html