Topic: [求助]为AppFuse添加一个PersonDAOTest的单元测试,出现错误 |
Print this page |
1.[求助]为AppFuse添加一个PersonDAOTest的单元测试,出现错误 | Copy to clipboard |
Posted by: down4u Posted on: 2005-10-31 15:59 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.appfuse.dao.PersonDAOTest' defined in null: Unsatisfied dependency expressed through bean property 'personDAO': set this property value or disable dependency checking for this bean at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.checkDependencies(AbstractAutowireCapableBeanFactory.java:961) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:822) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:200) at org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp(AbstractDependencyInjectionSpringContextTests.java:138) at junit.framework.TestCase.runBare(TestCase.java:125) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) 不知道是因何而起? |
2.Re:[求助]为AppFuse添加一个PersonDAOTest的单元测试,出现错误 [Re: down4u] | Copy to clipboard |
Posted by: floater Posted on: 2005-10-31 22:20 It's the first line:
It looks like you testcase has a property: personDAO and has dep checking enabled. Spring can't set this property and thus complains. make sure you have a setter for this property in your testcase and you have a valid ref to set this. |
3.Re:[求助]为AppFuse添加一个PersonDAOTest的单元测试,出现错误 [Re: floater] | Copy to clipboard |
Posted by: down4u Posted on: 2005-11-01 11:31 floater wrote: 检查了没问题啊,master看得出问题在哪里吗? PersonDAOTest.java package org.appfuse.dao; BaseDAOTestCase.java package org.appfuse.dao; applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> |
4.Re:[求助]为AppFuse添加一个PersonDAOTest的单元测试,出现错误 [Re: down4u] | Copy to clipboard |
Posted by: floater Posted on: 2005-11-01 11:38 where is the line to set the dao(calling your setter)? |
5.Re:[求助]为AppFuse添加一个PersonDAOTest的单元测试,出现错误 [Re: floater] | Copy to clipboard |
Posted by: down4u Posted on: 2005-11-01 13:18 floater wrote: 不是这样的吗?这是照着appfuse的文档做的 小可初学,望master教我 |
6.Re:[求助]为AppFuse添加一个PersonDAOTest的单元测试,出现错误 [Re: down4u] | Copy to clipboard |
Posted by: floater Posted on: 2005-11-02 11:05 hmm, I didn't notice you are using spring's testcase class. change your dao declaration to protected, not using private. |
7.Re:[求助]为AppFuse添加一个PersonDAOTest的单元测试,出现错误 [Re: floater] | Copy to clipboard |
Posted by: down4u Posted on: 2005-11-02 11:36 floater wrote: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.appfuse.dao.PersonDAOTest' defined in null: Unsatisfied dependency expressed through bean property 'personDAO': set this property value or disable dependency checking for this bean at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.checkDependencies(AbstractAutowireCapableBeanFactory.java:961) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:822) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:200) at org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp(AbstractDependencyInjectionSpringContextTests.java:138) at junit.framework.TestCase.runBare(TestCase.java:125) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) |
8.Re:[求助]为AppFuse添加一个PersonDAOTest的单元测试,出现错误 [Re: down4u] | Copy to clipboard |
Posted by: floater Posted on: 2005-11-04 21:49 You testcase extends Matt's testcase, which extends Spring's testcase. This means that your dao class in your testcase will be injected by Spring(unless you want to manually inject it). Spring's super class will look for all protected members and inject them from app context. It doesn't check private members. So in you testcase, you should declare dao as protected, rather than private. |
9.Re:[求助]为AppFuse添加一个PersonDAOTest的单元测试,出现错误 [Re: floater] | Copy to clipboard |
Posted by: down4u Posted on: 2005-11-05 12:09 floater wrote: private PersonDAO dao = null;改为protected PersonDAO dao = null; 可问题依旧,哎... |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |