[英]java.lang.IllegalStateException: Failed to load ApplicationContext
While Running a J Unit Test Case I am getting the Following Error : 在运行J单元测试用例时,出现以下错误:
java.lang.IllegalStateException: Failed to load ApplicationContext Caused by:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'dataSource' is defined
I Have Define the DataSource As "com.mchange.v2.c3p0.ComboPooledDataSource"
in .xml file. 我在.xml文件中将数据源定义为
"com.mchange.v2.c3p0.ComboPooledDataSource"
。
What may the reason Please help. 可能是什么原因请帮忙。
Is your bean defined exactly as follows (your exception suggests that beans' id
matters)? 您的bean定义是否完全如下(您的异常表明bean的
id
重要)?
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" ...
Also are you sure this XML file is picked up by JUnit? 您还确定JUnit会拾取此XML文件吗? Add some bogus characters at the beginning of the file, if the test fails while parsing the file, it's OK.
在文件的开头添加一些假字符,如果在分析文件时测试失败,则可以。 If you get the same error - the file isn't even parsed by JUnit runner.
如果您遇到相同的错误-JUnit运行器甚至不会解析该文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.