当我尝试从main方法运行我的代码时,我得到以下堆栈跟踪。
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.koushik.javabrains.DrawingApp.main(DrawingApp.java:19)
Caused by: java.lang.NullPointerException
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.<clinit>(DefaultListableBeanFactory.java:104)
    ... 1 more下面是代码。
FileSystemResource newResource = new FileSystemResource("spring.xml");
    BeanFactory factory = new XmlBeanFactory(newResource);
    Triangle triangle = (Triangle) factory.getBean("triangle");
    triangle.draw();谁能告诉我为什么我会得到这个异常,我如何解决它?在第一行抛出错误(新newResource =FileSystemResource FileSyste...)
提前感谢:)
发布于 2014-03-21 00:51:29
您应该改用ApplicationContext:
ApplicationContext ctx = new FileSystemXmlApplicationContext("spring.xml");但是,当然,您必须提供正确的配置文件位置:在我看来是完整路径。
https://stackoverflow.com/questions/22539658
复制相似问题