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

maven,spring,mybatis集成错误的更多相关文章

  1. SpringMVC+Spring+Mybatis -- 集成之旅

    准备 首先介绍一下,我的工具使用的是STS, 需要的童鞋可以到官网下载:http://spring.io/tools/sts/all 使用STS是因为她集成了Maven进行 “包“ 管理以及自带 We ...

  2. mybatis学习笔记(五) -- maven+spring+mybatis从零开始搭建整合详细过程(附demo和搭建过程遇到的问题解决方法)

    文章介绍结构一览 一.使用maven创建web项目 1.新建maven项目 2.修改jre版本 3.修改Project Facts,生成WebContent文件夾 4.将WebContent下的两个文 ...

  3. mybatis学习笔记(六) -- maven+spring+mybatis从零开始搭建整合详细过程(下)

    继续 mybatis学习笔记(五) -- maven+spring+mybatis从零开始搭建整合详细过程(上) 五.使用监听器启动Spring容器 1.修改pom.xml文件,添加Spring-we ...

  4. 框架基础学习之--详解web+maven+spring+mybatis+struts框架文件夹作用

    详解web+maven+spring+mybatis+struts框架文件夹作用 1.程序名 2.Mybatis,mybatis是数据持久层,就是和对象类有关系的东西 3.存放java文件,xml,p ...

  5. Maven+Spring+Mybatis+Security+Mysql简短的框架

    一段时间想搞个框架做开发,但是网上好多代码建立的都太杂乱.有的开源的东西我感觉用不了.本人太笨,不懂怎么上传到github上,就写在博客里,留作记录.以后用的时候也方便. 1.首先让我们看一下项目结构 ...

  6. Spring + Mybatis 集成原理分析

    由于我之前是写在wizNote上的,迁移过来比较浪费时间,所以,这里我直接贴个图片,PDF文件我上传到百度云盘了,需要的可直接下载. 地址:https://pan.baidu.com/s/12ZJmw ...

  7. Spring学习笔记--spring+mybatis集成

    前言: 技术的发展, 真的是日新月异. 作为javaer, 都不约而同地抛弃裸写jdbc代码, 而用各种持久化框架. 从hibernate, Spring的JDBCTemplate, 到ibatis, ...

  8. maven spring mybatis配置注意点

    以下对使用maven配置spring+mybatis项目时,完成基本的配置需要添加的一些信息进行说明.仅对mybatis部分进行列举. maven添加mybatis支持 <!-- mybatis ...

  9. spring + myBatis 常见错误:注解事务不回滚

    最近项目在用springMVC+spring+myBatis框架,在配置事务的时候发现一个事务不能回滚的问题. 刚开始配置如下:springMVC.xml配置内容: spring.xml配置内容 从上 ...

随机推荐

  1. 注意WPF中绑定使用的是引用类型

    绑定(Binding)是WPF提供的一个非常方便的特性,它可以方便的实现一个WPF的MVVM结构. 既可以实现数据驱动UI变化,也可以做到End-user在UI上的修改实现的反映到数据上. 但是有一点 ...

  2. Apache服务器部署ASP.NET网站

    资源罗列: apache如何支持asp.net 用 Apache 发布 ASP.NET 网站

  3. ASP.NET MVC NHibernate 整合

    请注明转载地址:http://www.cnblogs.com/arhat 在整合这三个技术之前,首先得说明一下整合的步骤,俗话说汗要一口一口吃,事要一件一件做.同理这个三个技术也是.那么在整合之前,需 ...

  4. 数据库获取前N条记录SQL Server与SQLite的区别

    在使用sql语句进行前20条记录查询时SQL Server可以这样写: 1: select top 20 * from [table] order by ids desc 2: select top ...

  5. sharepoint 2013 sp1

    http://www.microsoft.com/en-us/download/details.aspx?id=42544 http://soussi-imed.over-blog.com/artic ...

  6. C++的构造函数和析构函数

    1.构造函数和析构函数为什么没有返回值? 构造函数和析构函数是两个非常特殊的函数:它们没有返回值.这与返回值为void的函数显然不同,后者虽然也不返回任何值,但还可以让它做点别的事情,而构造函数和析构 ...

  7. JS数据类型&&typeof&&其他

    1. 5种基本数据类型: 1. String 2. Number 3. Boolean 4. Undefined 5. Null 2. 1种复杂数据类型:Object 3. 检测变量的数据类型:typ ...

  8. 为 UWP 应用提供的 .NET 网络 API

    [编者按]本文作者是 Windows networking 团队项目经理 Sidharth Nabar.在微软 Build 2015 大会上,.NET Core 5 作为开发 UWP(Universa ...

  9. easyui源码翻译1.32--NumberBox(数值输入框)

    前言 扩展自$.fn.validatebox.defaults.使用$.fn.numberbox.defaults重写默认值对象.下载该插件翻译源码 数值输入框是用来限制用户只能输入数值型数据的.他可 ...

  10. 169. Majority Element

    题目: Given an array of size n, find the majority element. The majority element is the element that ap ...