大佬教程收集整理的这篇文章主要介绍了java.lang.ExceptionInInitializerError在Spring中创建应用程序上下文时的异常,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在练习Spring,当我尝试实例化上下文时,我得到了一个java.lang.ExceptionInInitializerError异常.下面显示了Exception,我的代码跟随它.我从以前简化了我的实验.
例外
Oct 17,2012 5:54:22 PM org.springframework.context.support.AbstractApplicationContext preparerefresh
INFO: refreshing org.springframework.context.support.ClassPathXmlApplicationContext@570c16b7: startup date [Wed Oct 17 17:54:22 CDT 2012]; root of context hierarchy
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.springframework.context.support.AbstractrefreshableApplicationContext.createbeanfactory(AbstractrefreshableApplicationContext.java:195)
at org.springframework.context.support.AbstractrefreshableApplicationContext.refreshbeanfactory(AbstractrefreshableApplicationContext.java:128)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshbeanfactory(AbstractApplicationContext.java:535)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
at org.springframework.context.support.ClassPathXmlApplicationContext. beanfactory.<>beanfactory.java:105)
... 7 more
我的配置XML
http://www.springframework.org/scheR_419_11845@a/beans" xmlns:xsi="http://www.w3.org/2001/XMLscheR_419_11845@a-instance" xmlns:c="http://www.springframework.org/scheR_419_11845@a/c" xmlns:p="http://www.springframework.org/scheR_419_11845@a/p" xsi:scheR_419_11845@aLOCATIOn="http://www.springframework.org/scheR_419_11845@a/beans http://www.springframework.org/scheR_419_11845@a/beans/spring-beans-3.1.xsd">
我的考试班.
package helloworld;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class HelloWorldTest {
/**
* @param args
*/
public static void main(String[] args)
{
ApplicationContext context = new ClassPathXmlApplicationContext("HelloWorldTest-context.xml");
MessageContainer message = context.getBean(MessageContainer.class);
MessageOutputService service = context.getBean(MessageOutputService.class);
service.outputMessageToConsole(message);
}
}
无论如何,当Spring无法出于任何原因创建任何bean时,通常会抛出此异常(构造函数中的异常,resource loading issues,class loading issues等).我建议降低spring类和你自己的库的日志级别,看看下面发生了什么.
org.springframework=TRACE
com.gamemanagertest=TRACE
com.gamemanagertest=TRACE
以上是大佬教程为你收集整理的java.lang.ExceptionInInitializerError在Spring中创建应用程序上下文时的异常全部内容,希望文章能够帮你解决java.lang.ExceptionInInitializerError在Spring中创建应用程序上下文时的异常所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。