Spring org.springframework.beans.factory.BeanDefinitionStoreException:从ServletContext资源解析XML文档的IOException

时间:2018-05-11 14:12:32

标签: java spring spring-mvc spring-framework-beans

当我在Glassfish 4 / Tomcat 8上部署我的第一个Spring MVC应用程序时,我收到此错误

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/myFirstSpring-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/myFirstSpring-servlet.xml]

我认为我的Servlet配置存在问题。

的web.xml

    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
  <display-name>MyDemoApp</display-name>
    <servlet>
  <servlet-name>myFirstSpring</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
  <param-name>contexConfiguration</param-name>
  <param-value>/WEB-INF/config/myDemoApp-servletConfig.xml</param-value>
  </init-param>
  </servlet>
  <servlet-mapping>
  <servlet-name>myFirstSpring</servlet-name>
  <url-pattern>*.html</url-pattern>
  </servlet-mapping>

</web-app>

我的spring bean配置文件名为myDemoApp-servletConfig.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:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<mvc:annotation-driven></mvc:annotation-driven>

<context:component-scan base-package="com.demo.controllers"></context:component-scan>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="WEB=INF/jsp"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>][1]][1]

enter image description here

关于我做错了什么的任何线索?

此致

0 个答案:

没有答案