applicationcontext-Spring ApplicationContext .getBean()得不到 求大神帮忙

问题描述

Spring ApplicationContext .getBean()得不到 求大神帮忙

项目可以正常跑起来 但JUnit测试service 得不到指定的bean(serviceImpl) (http://img.ask.csdn.net/upload/201412/31/1420029219_816410.jpg)

解决方案

进行依赖注入的配置文件中的bean id="beanName" 要和你在实现代码中的getBean("beanName")一致

解决方案二:

而且我debug跟踪了 beans中有我需要的实例 但getbean方法得不到 求指点 (http://img.ask.csdn.net/upload/201412/31/1420030691_540750.jpg)

解决方案三:

每次跑到getbean是 都会直接跑到 找不到属性或者方法的异常上

时间: 2024-08-02 10:57:26

applicationcontext-Spring ApplicationContext .getBean()得不到 求大神帮忙的相关文章

spring 注入 多线程-spring多线程注入报错,求大神帮忙解决一下。。谢谢!!

问题描述 spring多线程注入报错,求大神帮忙解决一下..谢谢!! Error creating bean with name 'transactionManager': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implement

spring+junit4测试报错,求大神解答

问题描述 spring+junit4测试报错,求大神解答 java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308) at org.springframework.test.context.support.DependencyInjectio

求大神帮忙 spring aop 方式事务不回滚怎么搞?

问题描述 求大神帮忙 spring aop 方式事务不回滚怎么搞? spring 版本 4.1.7 代码如下: 表: CREATE TABLE users (id int(11) unsigned NOT NULL AUTO_INCREMENT,nick_name varchar(100) DEFAULT NULL,password varchar(100) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAU

spring mvc +hibernate4事务控制问题求大神解答

问题描述 spring mvc +hibernate4事务控制问题求大神解答 web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="

spring+springmvc+mybatis 报错。求大神指教。

问题描述 spring+springmvc+mybatis 报错.求大神指教. 严重: StandardWrapper.Throwableorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'index': Injection of autowired dependencies failed; nested exception is org.springframework.b

bean-请教一个Spring 配置sessionFactory的问题,求大神解答

问题描述 请教一个Spring 配置sessionFactory的问题,求大神解答 为什么我的sessionFactory只要配置packagesToScan就会报session无法初始化错误啊? org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/E:/apache-tomcat-6.0.44/w

spring mvc-springmvc配置mysql哪里错了,求大神帮忙

问题描述 springmvc配置mysql哪里错了,求大神帮忙 db.properties: driver=com.mysql.jdbc.Driver url=jdbc:mysql://114.215.207.30:3306busticket?useUnicode=true&characterEncoding=UTF-8 username=PBDB password=PBDB springmvc-servlet.xml: <?xml version="1.0" encod

spring-关于Spring的问题求大神帮忙

问题描述 关于Spring的问题求大神帮忙 tomcat启动的时候老是报错,Spring配置文件 org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from URL [file:/D:/JavaEE_Eclipse/Workspaces/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpweba

spring mvc 事务,操作多张表的时候,异常不回滚,求大神帮忙啊

问题描述 spring mvc 事务,操作多张表的时候,异常不回滚,求大神帮忙啊 @Override @Transactional(rollbackFor=Exception.class) public Boolean saveXkcq(String qian,String xh, Xk_cqb cqb, Rw_xkb rwXkb, Xk_xkb xkb) { Boolean type = false; try { if(qian!=null && qian.length()>0){