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. secureCRT简单上传、下载文件记录

    secureCRT简单上传.下载文件记录: 1)sz下载 -y 覆盖 2)rz上传 -y 覆盖 3)以上两个命令属于安装时包含在“Dial-up Networking Support"组中 ...

  2. wordpress mobile templates

    http://themeforest.net/category/wordpress/mobile http://themeforest.net/item/monolith-wp-theme-for-b ...

  3. iostream/fstream中的输入输出流指针的绑定,tie函数的使用。

      为了兼容c语言的输入输出,c++里面采用tie将输入输出流经行绑定,所以cin/cout并不是独立的.当执行cin时,cout同时会被执行.反之亦然. by defalut,cin is tied ...

  4. cursor:hand与cursor:pointer的区别介绍

    cursor:hand 与 cursor:pointer 的效果是一样的,都像光标指向链接一样,光标变成手行. cursor:hand :IE完全支持.但是在firefox是不支持的,没有效果. cu ...

  5. 在C#中关于excel的导入和导出操作

    一.先来看看最常见的导入操作吧! private void Import() { //打开excel选择框 OpenFileDialog frm = new OpenFileDialog(); frm ...

  6. 【无聊放个模板系列】HDU 1358 KMP

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...

  7. Android ExpandableListView的简单应用

    Expandablelistview1Activity.java package com.wangzhu.demoexpandablelistview; import java.util.ArrayL ...

  8. asp.net 弹出式日历控件 选择日期 Calendar控件

    原文地址:asp.net 弹出式日历控件 选择日期 Calendar控件 作者:逸苡 html代码: <%@ Page Language="C#" CodeFile=&quo ...

  9. java中的CAS

    转自:http://www.blogjava.net/mstar/archive/2013/04/24/398351.html Atomic 从JDK5开始, java.util.concurrent ...

  10. org.springframework.jdbc.datasource

    org.springframework.jdbc.datasource.DataSourceUtils /** * Actually obtain a JDBC Connection from the ...