Could not open ServletContext resource [/WEB-INF/SqlMapConfig.xml]

YYxlid 发布于 2013/07/18 17:20
阅读 1K+
收藏 0

服务器启动的时候出现这个问题,请问是什么原因

还有web.xml中如果去掉struts2的配置  就可以正常访问网页

但是如果加进去,就会出现 404的错误

求解

Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/SqlMapConfig.xml]
 at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:116)
 at org.springframework.orm.ibatis.SqlMapClientFactoryBean.buildSqlMapClient(SqlMapClientFactoryBean.java:315)
 at org.springframework.orm.ibatis.SqlMapClientFactoryBean.afterPropertiesSet(SqlMapClientFactoryBean.java:280)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1367)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1333)
 ... 26 more

applicationContext.xml

<?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:p="http://www.springframework.org/schema/p"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

 

<!-- 配置数据源 -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
         <property name="driverClassName" value="com.mysql.jdbc.Driver"/>        
         <property name="url" value="jdbc:mysql://127.0.0.1:3306/product"/>        
         <property name="username" value="root"/>        
         <property name="password" value="765805833"/>   
    </bean>
    <!--ibatis 操作对象-->
    <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
        <property name="configLocation">
            <value>WEB-INF/SqlMapConfig.xml</value> 
        </property>
        <property name="dataSource">
            <ref bean="dataSource"/>
        </property>
    </bean>
    <!-- 模板页面  -->
    <bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
        <property name="sqlMapClient">
            <ref bean="sqlMapClient"/>
        </property>
    </bean>
    <!-- 用户DAO类 -->
    <bean id="UserDAO" class="com.dao.UserDAO">
        <property name="sqlMapClientTemplate">
            <ref local="sqlMapClientTemplate"/>
        </property>
    </bean>
       <!--  spring 集成 struts2    -->
        <bean id="loginAction" class="com.web.Login"  scope="singleton">
            <property name="userDao">
                <ref bean="UserDAO" />
            </property>
        </bean>
</beans>

 

 

加载中
0
不正常的物种
不正常的物种
找不到配置文件,你确定你的配置文件在web-inf下吗? Caused by: java.io.FileNotFoundException:看下你的web.xml的名字是否和你的配置文件是否是一样的
0
Y
YYxlid
路径 名字 都一样 WEB-INF/SqlMapConfig.xml路径啊
返回顶部
顶部