No qualifying bean of type 'org.apache.catalina.User' available
2017-09-13 16:07
501 查看
org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type ‘com.wc.aop4.UserDao’ available与 java.lang.ClassCastException: com.sun.proxy.$Proxy15 cannot be cast to com.wc.aop4.UserDao
我的项目为
UserDao继承了IUSerDao接口
在我的Test.java中
问题就在这
我的UserDao实现了IUserDao接口,context.getBean(User.class)这个方法在对象实现接口的时候,生成的对象应是接口类型的。
改正:
当代码为:
报的错为:
我的项目为
UserDao继承了IUSerDao接口
在我的Test.java中
ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("com/wc/aop4/bean.xml"); UserDao userDao=(UserDao) context.getBean(UserDao.class); userDao.test(); context.close();
问题就在这
我的UserDao实现了IUserDao接口,context.getBean(User.class)这个方法在对象实现接口的时候,生成的对象应是接口类型的。
改正:
IUserDao userDao=(IUserDao) context.getBean(UserDao.class);
当代码为:
UserDao userDao=(UserDao) context.getBean("userDao");
报的错为:
相关文章推荐
- Noqualifying bean of type [org.apache.solr.client.solrj.SolrServer] is defined:expected single match
- No qualifying bean of type 'org.apache.velocity.app.VelocityEngine
- MyBatis映射错误,No qualifying bean of type 'xx.xx.UserDao' available
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.oskyhang.gbd.service.UserService] found for dependency: expected at least 1 bean which qualifies as aut
- No qualifying bean of type [org.apache.solr.client.solrj.SolrServer] found for dependency: expected
- No qualifying bean of type [org.springframework.data.mongodb.core.MongoTemplate]
- shiro错误 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.wan
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.lin
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [cn.itca
- Spring 定时器 No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined
- No qualifying bean of type 'com.yubai.bean.BeanWayService' available
- Spring 定时器 No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined
- No qualifying bean of type [com.dao.UserDao] found for dependency:
- No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined
- 解决:No qualifying bean of type [org.springframework.jdbc.core.JdbcTemplate] found for dependency
- No qualifying bean of type 'javax.sql.DataSource' available: more than one 'primary' bean found
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
- NoSuchBeanDefinitionException: No qualifying bean of type 'net.shopxx.service.xxxService' available:
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.cui