2012-02-20 51 views
1

错误消息是: - Error creating bean with name 'agencyDetailsInterfaceService' defined in class path resource尝试运行junit测试以进行dao hibernate操作时出现以下错误

堆栈跟踪如下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'agencyDetailsInterfaceService' defined in class path resource [spring/aas-service.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy51 implementing com.qbe.us.aas.service.IAgencyBatchOutService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'com.qbe.us.aas.service.impl.AgencyBatchOutService' for property 'agencyBatchOutService'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy51 implementing com.qbe.us.aas.service.IAgencyBatchOutService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.qbe.us.aas.service.impl.AgencyBatchOutService] for property 'agencyBatchOutService': no matching editors or conversion strategy found 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) 
    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:580) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) 
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) 
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93) 
    at com.qbe.us.aas.dao.hibernate.AccountDecPrintHibernateDaoJunitTest.setUp(AccountDecPrintHibernateDaoJunitTest.java:36) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:618) 
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) 
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) 
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) 
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) 
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) 
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) 
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) 
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) 
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) 
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236) 
    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.ConversionNotSupportedException: Failed to convert property value of type '$Proxy51 implementing com.qbe.us.aas.service.IAgencyBatchOutService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'com.qbe.us.aas.service.impl.AgencyBatchOutService' for property 'agencyBatchOutService'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy51 implementing com.qbe.us.aas.service.IAgencyBatchOutService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.qbe.us.aas.service.impl.AgencyBatchOutService] for property 'agencyBatchOutService': no matching editors or conversion strategy found 
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:462) 
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:499) 
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:493) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1371) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1330) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) 
    ... 35 more 
Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy51 implementing com.qbe.us.aas.service.IAgencyBatchOutService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.qbe.us.aas.service.impl.AgencyBatchOutService] for property 'agencyBatchOutService': no matching editors or conversion strategy found 
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231) 
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447) 
    ... 41 more 
+0

任何建议,为什么它可能会给这个错误。我相信我有所有必要的JAR文件 – AJ1986 2012-02-20 20:04:31

+0

是你的bean配置了注释或XML? – 2012-02-20 20:06:22

+0

如果你想读取发布的堆栈跟踪的完整第一行,你可以获得更多信息。 – madth3 2012-02-20 20:24:34

回答

1

可能是你申报的财产agencyBatchOutService作为实现类型而不是接口IAgencyBatchOutService

如果您需要使用该实现,请使用<aop:config proxy-target-class="true">来强制Spring使用cglib代理。

+0

它给所有我的Dao Junit同样的错误,所以它没有实现这个特定的场景.. – AJ1986 2012-02-21 20:20:47

+0

@ AJ1986你试试看吗?如果您将agencyDetailsInterfaceService中的agencyBatchOutService类型设置为IAgencyBatchOutService而不是AgencyBatchOutService,则会得到相同的错误? – 2012-02-21 21:43:21

相关问题