java - Spring Mvc java.io.FileNotFoundException - ApplicationContext.xml

标签 java xml spring-mvc java-io applicationcontext

applicationContext.xml 位于 WEB-INF 文件夹中,为什么我收到此错误:

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

Web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    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_3_0.xsd"
    id="crimeTrack" version="3.0">

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <context-param>
         <param-name>log4jConfigLocation</param-name> 
         <param-value>/WEB-INF/classes/log4j.properties</param-value>
     </context-param>

     <listener>
          <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> 
     </listener>

     <listener>
          <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener> 

    <servlet>
        <servlet-name>crimetrack</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>crimetrack</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
    <welcome-file>
      index.jsp
    </welcome-file>
    </welcome-file-list>

    <jsp-config>
        <taglib>
            <taglib-uri>/spring</taglib-uri>
            <taglib-location>/WEB-INF/tld/spring-form.tld</taglib-location>
        </taglib>
    </jsp-config>

</web-app>

最佳答案

就我而言,我需要做的就是从

移动 applicationContext.xml

src\main\webapp\WEB-INF\

src\main\resources\

关于java - Spring Mvc java.io.FileNotFoundException - ApplicationContext.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12574877/

相关文章:

java - 当你想在java中使用listfiles时,如果你没有权限,如何跳过文件?

java - 将 Java 频率排序转换为 Kotlin

java - 在 RHS 处引用 Spring XML 中的属性的属性?

java - 通过hibernate动态创建和切换数据库

java - 将时间间隔转换为不同语言的文本?

java - JTextField 突然变小了

PHP XML (DOM) 扩展 : installed but not listed in phpinfo in centos

java - 无法从 Spring Boot Controller 获取 web.xml 中的上下文参数

java - 我收到一个异常 : java. lang.IllegalStateException: getOutputStream() has been called for this response

spring - 在 Spring 验证期间包装 PropertyEditor 异常