mybaits-puls 在xml文件中写sql语句 会报错 Invalid bound statement (not found): com.keke.mapper.EmpMapper.Select5
//查询10号部门中工种为MANAGER和20部门中工种为CLERK的员工的信息。
@GetMapping("Select5")
public Result Select5(){
List<Emp> emps=empService.Select5();
System.out.println(emps);
return Result.success(emps);
}
//-----------------------------------------------------
用注解方式是正常的 把注解方式注释掉 试试xml写法
//@Select("select * from emp where job='MANAGER' and deptno=10 union select * from emp where job='CLERK' and deptno=20")
List<Emp> Select5();
//-------------------------------------------------------------
<mapper namespace="com.keke.mapper.EmpMapper">
<resultMap id="BaseResultMap" type="com.keke.domain.Emp">
<!--@mbg.generated-->
<!--@Table emp-->
<id column="EMPNO" jdbcType="INTEGER" property="empno"/>
<result column="ENAME" jdbcType="VARCHAR" property="ename"/>
<result column="JOB" jdbcType="VARCHAR" property="job"/>
<result column="MGR" jdbcType="INTEGER" property="mgr"/>
<result column="HIREDATE" jdbcType="DATE" property="hiredate"/>
<result column="SAL" jdbcType="DECIMAL" property="sal"/>
<result column="COMM" jdbcType="DECIMAL" property="comm"/>
<result column="DEPTNO" jdbcType="INTEGER" property="deptno"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO
</sql>
<select id="Select5" resultMap="BaseResultMap" >
select <include refid="Base_Column_List"></include> from emp where JOB='MANAGER' and DEPTNO=10
union
select <include refid="Base_Column_List"></include> from emp where JOB='CLERK' and DEPTNO=20
</select>
</mapper>
直接报错
Invalid bound statement (not found): com.keke.mapper.EmpMapper.Select5
感觉就是扫描不到 xml文件 (不知道是不是)
但是在配置文件却配置了
##配置数据源
spring:
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
username: root
password: 123456
max-active: 10 #最大活跃连接数
min-idle: 5 #小小的活跃连接数
validation-query: select 'x' #验证连接是否可用的sql
#监控页
stat-view-servlet:
enabled: true #开启数据源监控
login-username: keke
login-password: keke
allow: #允许连接的IP --白名单
deny: #不允许连接的IP --黑名单
url-pattern: /druid/*
#开启mybatis的配置
mybatis:
mapper-locations: classpath:mapper/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #配置sql控制台输出
在启动类上也配置了
@MapperScan(basePackages = {"com.keke.mapper"})
网上的常规方法都是试过了!有没有人指点下