maven,spring,mybatis集成错误
生活随笔
收集整理的這篇文章主要介紹了
maven,spring,mybatis集成错误
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
maven,spring,mybatis集成的時候單元測試junit測試沒問題,但mvn jetty:run 就報錯誤
錯誤:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.yd.bpm.rules.dao.GRoleDao.getParticipantList at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:196) ~[mybatis-3.3.1.jar:3.3.1] at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:44) ~[mybatis-3.3.1.jar:3.3.1] at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59) ~[mybatis-3.3.1.jar:3.3.1] 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? <!-- MyBatis配置 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自動掃描目錄, 省掉Configuration.xml里的手工配置 --> <property name="typeAliasesPackage" value="com.yd.bpm.common.model" /> <!-- 顯式指定Mapper文件位置 --> <property name="mapperLocations" value="classpath*:com/yd/bpm/**/*Mapper.xml" /> </bean> <!-- 掃描basePackage下所有以@MyBatisRepository標識的 接口--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.yd.bpm" /> <property name="annotationClass" value="com.yd.bpm.utils.spring.MyBatisRepository"/> </bean> dao:@MyBatisRepository("gRoleDao") public interface GRoleDao extends BaseDao<ActorPOJO> { /** * G_Role 角色查找 */ public List<ActorPOJO> getParticipantList(@Param(value="roleIds") String roleIds); } mapper.xml<?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"> <!-- namespace必須指向Dao接口 --> <mapper namespace="com.yd.bpm.rules.dao.GRoleDao"> <select id="getParticipantList" resultType="ActorPOJO" parameterType="String"> select t2.emp_id as id, t2.emp_name as name, 'person' as typeCode, '1' as sortNo from bpm_base_position t1 inner join bpm_base_employee t2 on t2.emp_id = t1.emp_id where t1.main_flag = 'y' and t1.role_id in (#{roleIds}) </select> </mapper>
反復查看后發現taget 目錄下 class 文件中有時沒有 mapper.xml ,這時就確認是maven沒有 src/main/java下的xml文件拷貝到 target目錄下了在網上搜了下pom.xml的配置方式
加上這個就可以了,如果是其它文件 properties 等 也用這種方式應該也可以解決
來自為知筆記(Wiz)
錯誤:
反復查看后發現taget 目錄下 class 文件中有時沒有 mapper.xml ,這時就確認是maven沒有 src/main/java下的xml文件拷貝到 target目錄下了在網上搜了下pom.xml的配置方式
加上這個就可以了,如果是其它文件 properties 等 也用這種方式應該也可以解決
來自為知筆記(Wiz)
轉載于:https://www.cnblogs.com/juforg/p/5228147.html
總結
以上是生活随笔為你收集整理的maven,spring,mybatis集成错误的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [国嵌攻略][085][共享内存通讯]
- 下一篇: 矩阵分解模型