首页 新闻 会员 周边

关于springboot与mybatis整合出现Invalid bound statement (not found): com.llfy.demo.dao.LoginMapper.getAll问题

0
[已解决问题] 解决于 2018-05-16 17:15

<?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.llfy.demo.dao.LoginMapper">
    <resultMap id="BannerResultMap" type="com.llfy.demo.entity.Login">
        <result property="id" column="id" jdbcType="INTEGER" />
        <result property="name" column="name" jdbcType="VARCHAR" />
        <result property="password" column="password" jdbcType="VARCHAR" />
    </resultMap>
    <select id="getAll" resultType="com.llfy.demo.entity.Login">
        select * from login
    </select>
</mapper>
package com.llfy.demo.dao;

import com.llfy.demo.entity.Login;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface LoginMapper {
    /**
     *  查询管理员列表。
     * @return
     */
    List<Login> getAll();
}
package com.llfy.demo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RestController;

@RestController
@SpringBootApplication
@MapperScan("com.llfy.demo.dao")
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

刘凌枫羽的主页 刘凌枫羽 | 菜鸟二级 | 园豆:355
提问于:2018-05-08 13:56
< >
分享
最佳答案
0

配置扫描mapper文件的路径了吗?

例如:
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://localhost:3306/数据库名?useSSL=false&useUnicode=true&characterEncoding=utf-8
username: root
password: wubiaowp
driver-class-name: com.mysql.jdbc.Driver
initialSize: 5
maxActive: 200
minIdle: 5
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20

mybatis:
mapper-locations: classpath:mapper/*_mapper.xml
type-aliases-package: com.util.model

奖励园豆:5
、熙和 | 小虾三级 |园豆:1508 | 2018-05-08 18:10

springboot不是支持注解吗,@MapperScan("com.llfy.demo.dao")

刘凌枫羽 | 园豆:355 (菜鸟二级) | 2018-05-08 18:16

sql使用注解是没有问题的,使用xml文件就会有这个错

刘凌枫羽 | 园豆:355 (菜鸟二级) | 2018-05-08 18:21

@刘凌枫羽: 你这个配置是扫描dao接口的; 自己看一下呀, @MapperScan("com.llfy.demo.dao"); 你的mapper文件是在resources/mapper下面的
你得告诉spring 去哪里把mapper文件加载进来 对吧?

、熙和 | 园豆:1508 (小虾三级) | 2018-05-08 19:21
其他回答(3)
0

resultMap="BannerResultMap"  你返回的是list,应该这么写吧

让我发会呆 | 园豆:2929 (老鸟四级) | 2018-05-08 14:31

这个并没有解决问题,应该不是

支持(0) 反对(0) 刘凌枫羽 | 园豆:355 (菜鸟二级) | 2018-05-08 14:34
0

最后怎么解决的啊

山抹微云君^^ | 园豆:274 (菜鸟二级) | 2018-08-28 16:29
0

////////

zomicc | 园豆:202 (菜鸟二级) | 2020-08-26 22:16
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册