日期:2014-05-18  浏览次数:20721 次

关于Spring的配置问题
一直提示Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreExceptionIOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.net.ConnectException: Connection timed out: connect
Caused by: java.net.ConnectException: Connection timed out: connect
------------------------------------------
以下是applicactionContext.xml配置信息
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.5.dtd">
<beans 
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:jasws="http://cxf.apache.org/jaxws" 
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
    
    <bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@127.0.0.1:1521:orcl">
</property>
<property name="username" value="boolea"></property>
<property name="password" value="admin"></property>
</bean>
    <bean name="personDao" class="demo.spring.jdbc.dao.impl.PersonDaoImpl">
        <property name="dataSource" ref="dataSource"/>
    </bean>
</beans>
----------------------------------

------解决方案--------------------
在搭框架的时候,楼主修改了applicationContext.xml文档的默认路径,原先是在/WEB-INF/,修改后的路径为项目/src下面,启动Tomcat时,故出现applicationContext.xml的路径错误。在web.xml中修改符合如下即可:

<context-param>
      <param-name>contextConfigLocation</param-name>
 &nb