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

hentai22 2015-11-13 10:42:50
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






...全文
197 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hentai22 2015-11-13
  • 打赏
  • 举报
回复
我知道了,谢谢了。我把实体类放错地方了。 注入的是entity包。我放在po包里了
hentai22 2015-11-13
  • 打赏
  • 举报
回复
我没用到 AccountCash
tony4geek 2015-11-13
  • 打赏
  • 举报
回复
Could not resolve type alias 'AccountCash'. Cause: java.lang.ClassNotFoundException: Cannot find class: AccountCash
baidu_16904007 2015-11-13
  • 打赏
  • 举报
回复
spring 创建bean对象时出错 未找到 daoSupport 这个对象 ,名字写错了吧...

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧