maven spring mybatis出现org.apache.ibatis.binding.BindingException: Invalid bound

     在使用maven+spring+mybatis时,配置文件没有问题,但运行时一直出现如下错误。后来发现在classes目录下面只有编译后的mapper.class文件,并没有mapper.xml文件。原因就是maven并没有将mapper.xml文件编译进去。

 错误信息如下:

2015-06-14 16:30:40.693:WARN:oejs.ServletHandler:/wee/user/users
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): org.wcy.wee.mapper.UserMapper.findUserList
	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:196)
	at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:44)
	at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
	at com.sun.proxy.$Proxy25.findUserList(Unknown Source)
	at org.wcy.wee.service.impl.UserServiceImpl.findUserList(UserServiceImpl.java:24)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
	at com.sun.proxy.$Proxy28.findUserList(Unknown Source)
	at org.wcy.wee.controller.UserController.list(UserController.java:22)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
	

  解决法办:在pom.xml中增加如下配置:

<resources>
	<resource>
		<directory>src/main/java</directory>
			<includes>
				<include>**/*.xml</include>
			</includes>
		<filtering>true</filtering>
	</resource>
</resources>

猜你喜欢

转载自wangchaoyong.iteye.com/blog/2219557
今日推荐