异常信息如下:
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);
}
}