当前位置: 代码迷 >> J2SE >> Junit 单元测试,出现以下有关问题,求大神解释解释
  详细解决方案

Junit 单元测试,出现以下有关问题,求大神解释解释

热度:637   发布时间:2016-04-23 19:35:49.0
Junit 单元测试,出现以下问题,求大神解释解释
org.springframework.beans.factory.BeanCreationException: Error creating bean 

with name 'daoSupport': Injection of resource dependencies failed; nested 

exception is org.springframework.beans.factory.BeanCreationException: Error 

creating bean with name 'sqlSessionTemplate' defined in class path resource 

[applicationContext.xml]: Cannot resolve reference to bean 'sqlSessionFactory' 

while setting constructor argument; nested exception is 

org.springframework.beans.factory.BeanCreationException: Error creating bean 

with name 'sqlSessionFactory' defined in class path resource 

[applicationContext.xml]: Invocation of init method failed; nested exception is 

org.springframework.core.NestedIOException: Failed to parse mapping resource: 

'file [D:\MyEclipse\zhenxindai\p2p\WebRoot\WEB-INF\classes\com\sm\mapper

\AccountCashMapper.xml]'; nested exception is java.lang.RuntimeException: Error 

parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error 

resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve 

type alias 'AccountCash'.  Cause: java.lang.ClassNotFoundException: Cannot find 

class: AccountCash
at 

org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postPro

cessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)
at 

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.pop

ulateBean(AbstractAutowireCapableBeanFactory.java:1120)
at 

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doC

reateBean(AbstractAutowireCapableBeanFactory.java:522)
at 

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre

ateBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory

$1.getObject(AbstractBeanFactory.java:295)
at 

org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingle

ton(DefaultSingletonBeanRegistry.java:223)
at 

org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean

(AbstractBeanFactory.java:292)
at 

org.springframework.beans.factory.support.AbstractBeanFactory.getBean

(AbstractBeanFactory.java:194)
at 

org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstanti

ateSingletons(DefaultListableBeanFactory.java:607)
at 

org.springframework.context.support.AbstractApplicationContext.finishBeanFactory

Initialization(AbstractApplicationContext.java:932)
at 

org.springframework.context.support.AbstractApplicationContext.refresh

(AbstractApplicationContext.java:479)
at 

org.springframework.context.support.ClassPathXmlApplicationContext.<init>

(ClassPathXmlApplicationContext.java:139)
at 

org.springframework.context.support.ClassPathXmlApplicationContext.<init>

(ClassPathXmlApplicationContext.java:93)
at com.test.TestUtil.<init>(TestUtil.java:8)
at com.test.DaoTest.<init>(DaoTest.java:7)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance

(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance

(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.junit.runners.BlockJUnit4ClassRunner.createTest

(BlockJUnit4ClassRunner.java:195)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall

(BlockJUnit4ClassRunner.java:244)
at org.junit.internal.runners.model.ReflectiveCallable.run

(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock

(BlockJUnit4ClassRunner.java:241)
at org.junit.runners.BlockJUnit4ClassRunner.runChild

(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild

(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
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)
Caused by: org.springframework.beans.factory.BeanCreationException: Error 

creating bean with name 'sqlSessionTemplate' defined in class path resource 

[applicationContext.xml]: Cannot resolve reference to bean 'sqlSessionFactory' 

while setting constructor argument; nested exception is 

org.springframework.beans.factory.BeanCreationException: Error creating bean 

with name 'sqlSessionFactory' defined in class path resource 

[applicationContext.xml]: Invocation of init method failed; nested exception is 

org.springframework.core.NestedIOException: Failed to parse mapping resource: 

'file [D:\MyEclipse\zhenxindai\p2p\WebRoot\WEB-INF\classes\com\sm\mapper

\AccountCashMapper.xml]'; nested exception is java.lang.RuntimeException: Error 

parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error 

resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve 

type alias 'AccountCash'.  Cause: java.lang.ClassNotFoundException: Cannot find 

class: AccountCash
at 

org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveRef

erence(BeanDefinitionValueResolver.java:329)
at 

org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveVal

ueIfNecessary(BeanDefinitionValueResolver.java:107)
at 

org.springframework.beans.factory.support.ConstructorResolver.resolveConstructor

Arguments(ConstructorResolver.java:629)
at 

org.springframework.beans.factory.support.ConstructorResolver.autowireConstructo

r(ConstructorResolver.java:148)
at 

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.aut

owireConstructor(AbstractAutowireCapableBeanFactory.java:1049)
at 

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre

ateBeanInstance(AbstractAutowireCapableBeanFactory.java:953)
at 

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doC

reateBean(AbstractAutowireCapableBeanFactory.java:490)
at 

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre

ateBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory

$1.getObject(AbstractBeanFactory.java:295)
at 

org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingle

ton(DefaultSingletonBeanRegistry.java:223)
at 

org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean

(AbstractBeanFactory.java:292)
at 

org.springframework.beans.factory.support.AbstractBeanFactory.getBean

(AbstractBeanFactory.java:198)
at 

org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowir

eResource(CommonAnnotationBeanPostProcessor.java:442)
at 

org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getReso

urce(CommonAnnotationBeanPostProcessor.java:416)
at 

org.springframework.context.annotation.CommonAnnotationBeanPostProcessor

$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:550)
at org.springframework.beans.factory.annotation.InjectionMetadata

$InjectedElement.inject(InjectionMetadata.java:150)
at 

org.springframework.beans.factory.annotation.InjectionMetadata.inject

(InjectionMetadata.java:87)
at 

org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postPro

cessPropertyValues(CommonAnnotationBeanPostProcessor.java:303)
... 36 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error 

creating bean with name 'sqlSessionFactory' defined in class path resource 

[applicationContext.xml]: Invocation of init method failed; nested exception is 

org.springframework.core.NestedIOException: Failed to parse mapping resource: 

'file [D:\MyEclipse\zhenxindai\p2p\WebRoot\WEB-INF\classes\com\sm\mapper

\AccountCashMapper.xml]'; nested exception is java.lang.RuntimeException: Error 

parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error 

resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve 

type alias 'AccountCash'.  Cause: java.lang.ClassNotFoundException: Cannot find 

class: AccountCash
at 

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.ini

tializeBean(AbstractAutowireCapableBeanFactory.java:1486)
at 

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doC

reateBean(AbstractAutowireCapableBeanFactory.java:524)
at 

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre

ateBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory

$1.getObject(AbstractBeanFactory.java:295)
at 







------解决思路----------------------
Could not resolve 

type alias 'AccountCash'.  Cause: java.lang.ClassNotFoundException: Cannot find 

class: AccountCash
  相关解决方案