大家过来看一看,瞧一瞧,有的spring报找不到xxxbean。。。纠结中!

问题描述

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileUploadService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'fileUploadDao' is definedat org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:300)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1064)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)at JUnit.test.ArticleInforServiceTest.setUpBeforeClass(ArticleInforServiceTest.java:42)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)at org.junit.runners.ParentRunner.run(ParentRunner.java:300)at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'fileUploadDao' is definedat org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:510)at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1056)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:435)at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:409)at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:541)at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:147)at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:297)... 28 more部分源码: /** */@Repositorypublic class FileUploadDAO extends BaseDAO<FileUpload> {} model类@Entity@Table(name="uploadfile")public class FileUpload implements Serializable{/** * 文件上传 */private static final long serialVersionUID = 7194554589429406803L;@Id @GeneratedValueprivate Integer id;@Column(nullable=false,length=80)private String filepath;@Temporal(TemporalType.TIMESTAMP)private Date uploadtime;public FileUpload(){}public FileUpload(String filepath) {this.filepath = filepath;}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getFilepath() {return filepath;}public void setFilepath(String filepath) {this.filepath = filepath;}public Date getUploadtime() {return uploadtime;}public void setUploadtime(Date uploadtime) {this.uploadtime = uploadtime;} /**接口类*/public interface IFileUploadService extends ServiceInterface<FileUpload> { public List<FileUpload> getFilePath(Integer[] ids); public List<FileUpload> findAllUploadFile(); @SuppressWarnings("rawtypes")public Page findAllUploadFile(Page page,List<PropertyFilter> pfList); @Component("fileUploadService")public class FileUploadService extends BaseService<FileUpload>implements IFileUploadService { @Resource(name="fileUploadDao")//@Resource//@Qualifier("uploadFileDao")private DAOInterface<FileUpload> fileUploadDao;public List<FileUpload> getFilePath(Integer[] ids) {// TODO Auto-generated method stubif(ids!=null && ids.length>0){StringBuffer jpql = new StringBuffer();String hql;for(int i=0; i<ids.length;i++){jpql.append('?').append((i+1)).append(',');}jpql.deleteCharAt(jpql.length()-1);hql=" select o.filepath from UploadFile o where o.id in("+ jpql.toString()+ ")";return null;}return null;}@SuppressWarnings({ "unchecked", "rawtypes" })public Page findAllUploadFile(Page page, List<PropertyFilter> pfList) {//初始化hqlStringBuffer hql=new StringBuffer("from UploadFile");//设置查询条件String condition= QueryUtil.toSqlString(pfList, true);hql.append(condition);//查找所有用户的总条数int totalCount=this.fileUploadDao.findCountBySql(hql.toString());page.setTotalCount(totalCount);//是否存在排序if(page.isOrderBySetted()){hql.append(page.getOrder());}List<FileUpload> list=this.fileUploadDao.findList(hql.toString(), page.getPageNo(), page.getPageSize());//查出结果集page.setResult(list);return page;}public List<FileUpload> findAllUploadFile() {String hql="from UploadFile";return this.fileUploadDao.findList(hql);}public DAOInterface<FileUpload> getFileUploadDao() {return fileUploadDao;}public void setFileUploadDao(DAOInterface<FileUpload> fileUploadDao) {this.fileUploadDao = fileUploadDao;}@Overrideprotected DAOInterface<FileUpload> getDAO() {// TODO Auto-generated method stubreturn fileUploadDao;} 问题补充:<div class="quote_title">qiankun 写道</div><div class="quote_div">@Repository("fileUploadDao")<br />public class FileUploadDAO extends BaseDAO&lt;FileUpload&gt; {&nbsp;&nbsp; <br />&nbsp; <br />}试试</div><br />谢谢!既然可以哦,后来我用这个模式@Resource(type="xxxx.class")junit的时候可以!但是部署的时候不行。。。。!<br />谢谢<img src="/images/smiles/icon_biggrin.gif"/>

解决方案

@Repository("fileUploadDao")public class FileUploadDAO extends BaseDAO<FileUpload> { }试试

时间: 2024-10-22 05:35:17

大家过来看一看,瞧一瞧,有的spring报找不到xxxbean。。。纠结中!的相关文章

session-新人求助,希望路过大神点进来瞧一瞧帮帮我

问题描述 新人求助,希望路过大神点进来瞧一瞧帮帮我 防止暴力登录限制(连续五次失败2小时内容禁止登录),求代码,希望大神不要讲思路,思路懂,但是写不出来.... 希望用session或者cookies来实现 不要用数据库 ,老总抽风,就想做一个这个功能装装样子,内部系统,没外人使用,所以不存在什么安全不安全的 ,不会清空cookies或者关闭浏览器session这些情况,哪位大神做过呢,希望能把源码给小弟,在此拜谢了....或者发345876035@qq.com也行 解决方案 自己努力看一下CO

装SDK时遇到一个非常奇怪的问题,各位都来瞧一瞧,指点一下

问题描述 装SDK时遇到一个非常奇怪的问题,各位都来瞧一瞧,指点一下 装Android4.0以上的时候没有任何问题,但是装4.0以下版本全部显示与windows不兼容.....这是什么鬼?以前从未遇到过啊 解决方案 集成tiles3时遇到的问题mark一下 解决方案二: http://blog.csdn.net/pathuang68/article/details/8233107

数据结构运行出错,各位大神走一走,瞧一瞧!!!感激不尽!!!

问题描述 数据结构运行出错,各位大神走一走,瞧一瞧!!!感激不尽!!! #include #include #define ok 1; #define overflow 0; typedef int status; typedef int elemtype; const int list_init_size=100; const int listincrement=10; typedef struct{ elemtype elem; int length; int listsize; }seql

数据类型-写个json对象demo瞧一瞧,json对象都有什么特点啊

问题描述 写个json对象demo瞧一瞧,json对象都有什么特点啊 写个json对象demo瞧一瞧,json对象都有什么特点啊 json对象和map对象和list对象有何异同 解决方案 var obj={""a"":1b"":2}就是这种,,和map很像,,就是键值对的 传值方式 解决方案二: json就是键值对var obj={""employees"": [{ ""firstNam

java 7-求第m个到第n个素数之间的素数和,求帮忙看下哪里错了 提取数组求和的时候总是在数组中出现0

问题描述 求第m个到第n个素数之间的素数和,求帮忙看下哪里错了 提取数组求和的时候总是在数组中出现0 public class All { public static void main(String[] args) { int a[] = new int[200]; //将前200个数中的素数提取出来放入数组a中 for(int i = 1 ; i < 200 ; i ++){ boolean isPrime = true; for(int k = 2 ; k < i ; k ++){ if

帮我看一下,这个代码我怎么找不到上传文件的地方呢

问题描述 帮我看一下,这个代码我怎么找不到上传文件的地方呢 基本是按http://blog.csdn.net/jingdian14/article/details/7885416这个来写的 但是好像没有上传文件啊,如果有,哪一个语句是是往uri上传文件?运行winform每次返回的returnvalue都是0,那不就表示根本没完成上传吗,为什么?我也测试过了这个returnvalue=0确实是 else if (sReturnString == "Error") { returnVal

c语言-看了不下十遍,看不出语法错误在哪 C语言,在VS2013中运行

问题描述 看了不下十遍,看不出语法错误在哪 C语言,在VS2013中运行 #include //主函数 int main() { int max(int x, int y); int a, b, c; scanf("%d,%d", &a, &b); c = max(a,b); printf("max=%dn", c); return 0; } //求两个整数中的较大者的max函数 int max(int x, int y) { int z; if (

应用服务器-大牛们看一下,服务器为什么会报异常啊

问题描述 大牛们看一下,服务器为什么会报异常啊 [#|2015-09-14T19:42:38.868+0800|SEVERE|inforsuite9.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging.LogManagerService|_ThreadID=20;_ThreadName=Thread-2;|RO调用中,执行方法异常budget.control...IBudgetControlContext.getYs

走过路过,请进来看一看,瞧一瞧了。。。

问题描述 本人正在找工作中,想找一份java程序员的工作,本人有两年的工作经验,在项目开发过程主要负责独自完成所有模块功能代码的开发和实现.下面是我的个人简历.希望能得到上班的机会,谢谢!个人简历求职意向:JAVA软件开发基本情况:姓名:王帆性别:男年龄:23岁学历:本科联系方式:13146873242毕业院校:北京应用技术大学专业技能:主流框架:Spring.Hibernate.Struts开发技术:Jsp.JavaBean.Servlet.JDBC.JavaScript.Ajax.Jstl.