简体   繁体   English

java.lang.IllegalStateException:无法加载ApplicationContext

[英]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.

相关问题 @WebMvcTest 失败,出现 java.lang.IllegalStateException:无法加载 ApplicationContext - @WebMvcTest fails with java.lang.IllegalStateException: Failed to load ApplicationContext SpringBoot + Mybatis + MySQL,java.lang.IllegalStateException:无法加载ApplicationContext - SpringBoot + Mybatis + MySQL, java.lang.IllegalStateException: Failed to load ApplicationContext 测试 java.lang.IllegalStateException: 加载 ApplicationContext 失败 - Test java.lang.IllegalStateException: Failed to load ApplicationContext Junit错误:java.lang.IllegalStateException:无法加载ApplicationContext - Junit error :java.lang.IllegalStateException: Failed to load ApplicationContext Spring JUnit-java.lang.IllegalStateException:无法加载ApplicationContext - Spring JUnit - java.lang.IllegalStateException: Failed to load ApplicationContext 测试失败:java.lang.IllegalStateException:加载ApplicationContext失败 - Test Failure : java.lang.IllegalStateException: Failed to load ApplicationContext java.lang.IllegalStateException:无法加载 ApplicationContext 错误 java spring-boot - java.lang.IllegalStateException: Failed to load ApplicationContext error java spring-boot Java Spring 测试没有 Spring 启动 - 错误 Z93F725A07423FE1C8846F448IllegalZlangException:FFailed 加载应用程序。 - Java Spring testing without Spring Boot - error java.lang.IllegalStateException: Failed to load ApplicationContext 使用Spring编写数据库单元测试:java.lang.IllegalStateException:无法加载ApplicationContext - Writing DB Unit Tests with Spring : java.lang.IllegalStateException: Failed to load ApplicationContext java.lang.IllegalStateException:使用HSQL嵌入式数据库运行单元测试时,无法加载ApplicationContext - java.lang.IllegalStateException: Failed to load ApplicationContext when running unit test with HSQL embedded database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM