注解@Resource奇葩报错问题解决

原创 2017年06月20日 17:51:13

一、起源

这个问题困扰我好久,前几天也遇到过,于是网上查找资料,无果,今天又是这个问题,无意操作居然好了,非常神奇,特此记录。

二、问题

六月 20, 2017 5:44:47 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reportSignConR': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reportSignSer': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'signMapper' must be of type [com.zs.dao.ReportSignMapper], but was actually of type [com.sun.proxy.$Proxy43]
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:307)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4717)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reportSignSer': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'signMapper' must be of type [com.zs.dao.ReportSignMapper], but was actually of type [com.sun.proxy.$Proxy43]
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:307)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:445)
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:419)
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:544)
	at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:155)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:304)
	... 22 more
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'signMapper' must be of type [com.zs.dao.ReportSignMapper], but was actually of type [com.sun.proxy.$Proxy43]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:376)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:445)
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:419)
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:544)
	at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:155)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:304)
	... 35 more

service:

package com.zs.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.zs.dao.ReportSignMapper;
import com.zs.entity.ReportSign;
import com.zs.entity.ReportSignKey;
import com.zs.entity.other.EasyUIAccept;
import com.zs.entity.other.EasyUIPage;
import com.zs.entity.other.ReportSignBean;
import com.zs.service.ReportSignSer;

@Service("reportSignSer")
public class ReportSignSerImpl implements ReportSignSer{

	private Logger log=Logger.getLogger(getClass());
	@Resource
	private ReportSignMapper signMapper;
	
	public EasyUIPage queryFenye(EasyUIAccept accept) {
		/*if (accept!=null) {
			Integer page=accept.getPage();
			Integer size=accept.getRows();
			if (page!=null && size!=null) {
				accept.setStart((page-1)*size);
				accept.setEnd(page*size);
			}
			List list=signMapper.queryFenye(accept);
			int rows=signMapper.getCount(accept);
			return new EasyUIPage(rows, list);
		}*/
		return null;
	}

	public Integer add(ReportSign obj) {
		// TODO Auto-generated method stub
		return null;
	}

	public Integer update(ReportSign obj) {
		// TODO Auto-generated method stub
		return null;
	}

	public Integer delete(ReportSignKey id) {
		// TODO Auto-generated method stub
		return null;
	}

	public ReportSign get(ReportSignKey id) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<ReportSignBean> obtainOfCtmAndProvince(Date d1,Date d2) {
//		return signMapper.obtainOfCtmAndProvince(d1, d2);
		return null;
	}

}

三、解决

只需要把private ReportSignMapper signMapper;改为private ReportSignMapper reportSignMapper;

只要把类名复制,将首字母小写即可,谁能解释。


版权声明:本文是我的原创文章,未经我的允许不得转载,违者必究<(-︿-)>。

相关文章推荐

CAD与VB报错问题解决方案.txt

  • 2015年08月22日 22:45
  • 456B
  • 下载

JavaEE_Mybatis_SpringMVC_整合开发奇葩问题1:dataSource报错?

问题 DEBUG日志 DEBUG [main] - Listing file:/D:/Java_Web_Project/SpringMvc_MyBatis_test2/WebRoot/WEB-INF...

ORACLE启动报错常见问题解决

  • 2008年05月30日 17:25
  • 33KB
  • 下载

Java连接虚拟机的redis报错问题解决办法

直奔主题,Java连接虚拟机报错,代码如下: public class TestPing { public static void main(String[] args) { Jedis jed...

虚拟机报错问题解决

  • 2013年05月21日 11:20
  • 22KB
  • 下载

Ubuntu vi 上下左右变ABCD及 apt-get install报错问题解决方法

Ubuntu  vi 上下左右变ABCD问题解决方法 错误问题:vi上下左右键显示为ABCD的问题 解决方法:  只要依次执行以下两个命令即可完美解决Ubuntu下vi编辑器方向键变字母的问题。...
  • sidely
  • sidely
  • 2014年10月21日 09:05
  • 11287

Eclipse for JavaEE导入工程报错问题解决

eclipse import dynamic web project Eclipse导入web工程问题
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:注解@Resource奇葩报错问题解决
举报原因:
原因补充:

(最多只允许输入30个字)