• 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 等 也用这种方式应该也可以解决




  • 相关阅读:
    【Vue】Re19 Promise
    【Vue】Re17 Router 第四部分(参数传递,守卫函数)
    【Vue】Re16 Router 第三部分(懒加载、子路由)
    【Vue】Re15 Router 第二部分(缺省路由、动态路由)
    【Vue】Re14 Router 第一部分(入门案例)
    【Vue】Re13 CLI(Command Line Interface)
    【Vue】Re12 Webpack 第三部分(插件、热部署、配置分离)
    【Vue】Re11 Vue 与 Webpack
    【Vue】Re10 Webpack 第二部分(Loader)
    11-26日测试
  • 原文地址:https://www.cnblogs.com/juforg/p/5228147.html
Copyright © 2020-2023  润新知