java.lang.IllegalStateException:无法加载ApplicationContext
运行 J Unit 测试用例时,我收到以下错误:
java.lang.IllegalStateException: Failed to load ApplicationContext Caused by:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'dataSource' is defined
我已在 .xml 文件中将数据源定义为 "com.mchange.v2.c3p0.ComboPooledDataSource"
。
可能是什么原因请帮忙。
While Running a J Unit Test Case I am getting the Following Error :
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.
What may the reason Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 bean 是否完全按照以下方式定义(您的异常表明 bean 的
id
很重要)?另外,您确定 JUnit 已获取此 XML 文件吗?在文件开头添加一些假字符,如果解析文件时测试失败,也没关系。如果您遇到相同的错误 - JUnit 运行程序甚至不会解析该文件。
Is your bean defined exactly as follows (your exception suggests that beans'
id
matters)?Also are you sure this XML file is picked up by JUnit? 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.