org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/ApplicationContext.xml]; nested exception is java.lang.NullPointerException2013-5-23 10:28:41 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/ApplicationContext.xml]; nested exception is java.lang.NullPointerException
配置 spring 启动 Tomcat报的错
Spring异常Tomcat
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- spring的监听以及配置文件加载信息 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<!-- 上面配置的spring配置文件的路径,区分大小写 -->
<param-value>WEB-INF/ApplicationContext.xml</param-value>
<!-- <param-value>classpath:ApplicationContext.xml</param-value> -->
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>testServlet</servlet-name>
<servlet-class>org.yhb.test.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping> </web-app>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http: /
www.springframework.org / schema / beans / spring-beans-2.5.xsd http: /
www.springframework.org / schema / context http: /
www.springframework.org / schema / context / spring-context-2.5.xsd
http: / www.springframework.org / schema / aop http: /
www.springframework.org / schema / aop / spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- 这个地方开始放置所有bean的配置信息 -->
<!--配置jdbc.properties文件的位置信息,路径还是区分大小写 -->
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="WEB-INF/jdbc.properties" />
</bean>
<!-- 读取jdbc.properties文件,配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${driver}" />
<property name="url" value="${url}" /> <property name="username" value="${user}" />
<property name="password" value="${password}" /> <!-- 数据库连接池配置 -->
<property name="initialSize" value="60" /><!-- 初始化连接数量 -->
<property name="maxActive" value="100" /><!-- 最大连接数量 -->
<property name="maxIdle" value="50" /><!-- 最大空闲连接数量 -->
<property name="minIdle" value="10" /><!-- 最小空闲连接数量 -->
</bean>
<!-- 配置实现类,注入数据源 -->
<bean id="ITestTableDAOImpl" class="org.yhb.vo.impl.ITestTableDAOImpl">
<property name="dataSource" ref="dataSource" />
</bean> <!-- 配置service类,注入上面的实现类 -->
<bean id="ITestTableDAOService" class="org.yhb.vo.service.ITestTableDAOService">
<property name="testImpl" ref="ITestTableDAOImpl" />
</bean>
</beans>