Java Spring类路径XmlApplicationContext NullPointerException

Java Spring类路径XmlApplicationContext NullPointerException,java,xml,spring,spring-mvc,Java,Xml,Spring,Spring Mvc,尝试使用弹簧。xml文件位于src下。我已经找过了,找不到问题。似乎找不到xml文件 我得到以下错误: Exception in thread "main" java.lang.ExceptionInInitializerError at org.springframework.core.env.AbstractEnvironment.suppressGetenvAccess(AbstractEnvironment.java:406) at org.springframework.cor

尝试使用弹簧。xml文件位于src下。我已经找过了,找不到问题。似乎找不到xml文件

我得到以下错误:

    Exception in thread "main" java.lang.ExceptionInInitializerError
at org.springframework.core.env.AbstractEnvironment.suppressGetenvAccess(AbstractEnvironment.java:406)
at org.springframework.core.env.AbstractEnvironment.getSystemEnvironment(AbstractEnvironment.java:368)
at org.springframework.core.env.StandardEnvironment.customizePropertySources(StandardEnvironment.java:79)
at org.springframework.core.env.AbstractEnvironment.<init>(AbstractEnvironment.java:124)
at org.springframework.core.env.StandardEnvironment.<init>(StandardEnvironment.java:54)
at org.springframework.context.support.AbstractApplicationContext.createEnvironment(AbstractApplicationContext.java:444)
at org.springframework.context.support.AbstractApplicationContext.getEnvironment(AbstractApplicationContext.java:283)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.resolvePath(AbstractRefreshableConfigApplicationContext.java:122)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.setConfigLocations(AbstractRefreshableConfigApplicationContext.java:80)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:137)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at org.hancock.javabrains.DrawingApp.main(DrawingApp.java:13)
Caused by: java.lang.NullPointerException
at org.springframework.core.SpringProperties.<clinit>(SpringProperties.java:58)
... 12 more
xml(Beans.xml):


通过提供完整的文件路径来尝试此操作

ApplicationContext ctx = new FileSystemXmlApplicationContext("Beans.xml");

显示整个StackTrace.xml文件的名称是什么?是
Beans.xml
还是
Beans.xml
。它被称为Beans.xml。类加载器为空。您在哪个环境中运行此应用程序?执行环境:JavaSE-1.7似乎您正在使用spring 4.0之前的库,但在xml模式位置中引用了spring-beans-4.0.xsd。尝试使用最新的spring库并查看。Spring4没有文件SpringProperties.java。所有JAR都说是4.0.3。如果我把它改为spring-beans-3.0.xsd,我会得到同样的错误。
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">

<bean id="helloWorld" class="org.hancock.javabrains.HelloWorld">
   <property name="message" value="Hello World!"/>
</bean>

</beans>
ApplicationContext ctx = new FileSystemXmlApplicationContext("Beans.xml");