zoukankan      html  css  js  c++  java
  • maven,spring,mybatis集成错误

    maven,spring,mybatis集成的时候单元测试junit测试没问题,但mvn jetty:run 就报错误
    错误:
    1. org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.yd.bpm.rules.dao.GRoleDao.getParticipantList
    2. at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:196) ~[mybatis-3.3.1.jar:3.3.1]
    3. at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:44) ~[mybatis-3.3.1.jar:3.3.1]
    4. at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59) ~[mybatis-3.3.1.jar:3.3.1]
    5. at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) ~[mybatis-3.3.1.jar:3.3.1]
    未绑定mapper.xml  正常理解是 mapp.xml 没对应上 dao.java 的方法导致的,但是检查很多遍都能够对应上
    applicationContext.xml 
    1. <!-- MyBatis配置 -->
    2. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    3. <property name="dataSource" ref="dataSource" />
    4. <!-- 自动扫描目录, 省掉Configuration.xml里的手工配置 -->
    5. <property name="typeAliasesPackage" value="com.yd.bpm.common.model" />
    6. <!-- 显式指定Mapper文件位置 -->
    7. <property name="mapperLocations" value="classpath*:com/yd/bpm/**/*Mapper.xml" />
    8. </bean>
    9. <!-- 扫描basePackage下所有以@MyBatisRepository标识的 接口-->
    10. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    11. <property name="basePackage" value="com.yd.bpm" />
    12. <property name="annotationClass" value="com.yd.bpm.utils.spring.MyBatisRepository"/>
    13. </bean>
    dao:
    1. @MyBatisRepository("gRoleDao")
    2. public interface GRoleDao extends BaseDao<ActorPOJO> {
    3. /**
    4. * G_Role 角色查找
    5. */
    6. public List<ActorPOJO> getParticipantList(@Param(value="roleIds") String roleIds);
    7. }
    mapper.xml
    1. <?xml version="1.0" encoding="UTF-8" ?>
    2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    4. <!-- namespace必须指向Dao接口 -->
    5. <mapper namespace="com.yd.bpm.rules.dao.GRoleDao">
    6. <select id="getParticipantList" resultType="ActorPOJO" parameterType="String">
    7. select
    8. t2.emp_id as id,
    9. t2.emp_name as name,
    10. 'person' as typeCode,
    11. '1' as sortNo
    12. from bpm_base_position t1
    13. inner join bpm_base_employee t2 on t2.emp_id = t1.emp_id
    14. where t1.main_flag = 'y'
    15. and t1.role_id in (#{roleIds})
    16. </select>
    17. </mapper>

    反复查看后发现taget 目录下 class 文件中有时没有 mapper.xml ,这时就确认是maven没有 src/main/java下的xml文件拷贝到 target目录下了
    在网上搜了下pom.xml的配置方式

    加上这个就可以了,如果是其它文件 properties 等 也用这种方式应该也可以解决




  • 相关阅读:
    【HTML】使用css3和html给网站添加上春节灯笼特效
    【CSS】学习笔记2 字体设置
    【CSS】学习笔记3 段落设置
    【CSS】学习笔记1 使用CSS样式表
    正则
    图片懒加载
    uni-app-组件
    uni-app-condition(条件)启动模式
    uni-app-页面
    uni-app项目目录和开发规范
  • 原文地址:https://www.cnblogs.com/juforg/p/5228147.html
Copyright © 2011-2022 走看看