NoSuchBeanDefinitionException

异常信息如下:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘zybCoreBS‘ is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:387)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:971)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)
at com.tansun.scf.zyb.intf.test.LoadPropertis.getBean(LoadPropertis.java:25)
at com.tansun.scf.zyb.intf.test.Test01.setUp(Test01.java:24)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
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)

我的application-channel-test.xml文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

<bean id="zybCoreBS" class="com.tansun.scf.zyb.intf.core.service.impl.ZybCoreBSImpl">
<property name="bussCommonBS">
<ref bean="bussCommonBS" />
</property>
</bean>

<bean id="zybCmsBS" class="com.tansun.scf.zyb.intf.cms.service.impl.ZybCmsBSImpl">
<property name="bussCommonBS">
<ref bean="bussCommonBS" />
</property>
</bean>

<bean id="bussCommonBS" class="com.tansun.scf.common.service.impl.BussCommonBSImpl">
<property name="sysparamBS">
<ref bean="sysparamBS" />
</property>
</bean>

</beans>

单元测试调zybCmsBS中的方法可以跑,但是当调到bussCommonBS的方法时报空指针异常,已经注入了还报这个说不过去,于是测试zybCoreBS,没想到直接报错如上,再测试直接调bussCommonBS,报空指针异常,分析了半天也不知道是什么原因,有大神可以指点下么?

我的Test类如下:

public class Test01 extends LoadPropertis {

// public TestAction testAction;
private IZybCmsBS zybCmsBS;
// private IBussCommonBS bussCommonBS;
private IZybCoreBS zybCoreBS;

protected void setUp() throws Exception{
super.setUp();
zybCmsBS = (IZybCmsBS)this.getBean("zybCmsBS");
// bussCommonBS = (IBussCommonBS)this.getBean("bussCommonBS");
zybCoreBS = (IZybCoreBS)this.getBean("zybCoreBS");
}

protected void tearDown()throws Exception{
super.tearDown();

}

public void test01() {
//BlacklistInVO blacklistInVO = new BlacklistInVO();
CurrAccoInVo currAccoInVo = new CurrAccoInVo();
try {
// zybCmsBS.blacklistInfoSync(blacklistInVO);
zybCoreBS.currAccoQuery(currAccoInVo);
} catch (Exception e) {
System.out.println("失败");
}
// Date date = bussCommonBS.getBussDate();
// System.out.println(date);

}
}

时间: 2024-10-14 22:46:30

NoSuchBeanDefinitionException的相关文章

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named &#39;App&#39; is defined

工具:Eclipse mars 环境:jdk1.8 说明:这是在学习Spring Task时遇到的一个bug,代码如下: 定时任务类: package com.task.test; import java.util.Date; import org.springframework.stereotype.Component; @Component public class App { public void execute1(){ System.out.printf("Task: %s, Curr

【转】 Spring NoSuchBeanDefinitionException原因分析

摘要:本文译自Eugen Paraschiv文章spring NoSuchBeanDefinitionException 原文链接: http://www.baeldung.com/spring-nosuchbeandefinitionexception 感谢Eugen Paraschiv对此所做的研究. 概述 在本文中,我将通过实例向你展示Spring 中org.springframework.beans.factory.NoSuchBeanDefinitionException 出现的原因.

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException

1.错误描写叙述 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help | start | stop } 2014-7-13 18:02:58 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.29 usi

nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException

You should autowire interface AbstractManager instead of class MailManager. If you have different implemetations of AbstractManager you can write @Component("mailService") and then @Autowired @Qualifier("mailService") combination to au

spring Boot异步操作报错误: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type &#39;com.self.spring.springboot.Jeep&#39; available

我也是最近开始学习Spring Boot,在执行异步操作的时候总是汇报如下的错误: Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.self.spring.springboot.Jeep' available at org.springframework.beans.factory.sup

(待解答)Spring报错:Exception in thread &quot;main&quot; org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named &#39;car&#39; is defined

新建了一个Spring工程,有2个类:HelloWorld.Car.在Main.java文件里获取类时,发现只能获取到HelloWorld类,不能获取到Car类. HelloWorld.java: 1 package com.tt.spring.beans; 2 3 public class HelloWorld { 4 5 private String name; 6 7 public void setName(String name) { 8 System.out.println("hell

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named &#39;testService&#39; is defined

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'testService' is defined(1)这个错误的原因是编译器找不到bean 的注入,还可能是你的注入名字写错了. (2)spring的配置文件 书写错误,没有加入自动扫描功能 这句<context:component-scan base-package="包名"></context:compone

mybatis整合ss的时候,无法autowire使用mapper的自动注入,找不到bean:NoSuchBeanDefinitionException

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDaoImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: p

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named &#39;springSessionRepositoryFilter&#39; is defined

spring-session 集成redis,web.xml配置filter时候出现  No bean named 'springSessionRepositoryFilter' is defined 从spring给出的异常可以看出是没有取到这个bean,然后纠结了半天,各种版本切换找问题依旧未解决,然后Google找了半天, 也是没有找到问题解决方式,stackoverflow上也有许多人提出该问题,但是看了下面的解决方式,然并卵,一个都没用... 只能试着自己解决了. 既然没找到bean,

报错!!!!!!!!!!!org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named &#39;springSessionRepositoryFilter&#39; is defined

报错!!!!!!!!!!! 因用maven项目不是很熟练,经常在Maven转Web项目(为什么要转web项目?因为要在tomcat中跑起来.maven项目好像是可以直接部署到tomcat的,或集成tomcat插件,还没尝试过)的时候会出现很奇怪的问题.下面的一个报错就是最近经常遇到的一个问题.因为每次遇到它时,都会花很长时间去排查,所以在此把它记录下来,以便后面再遇到此问题时,顺利过坑.报错如下: org.springframework.beans.factory.NoSuchBeanDefin