关于java.io.FileNotFoundException: class path resource [spring/springmvc.xml]异常的问题解决-程序员宅基地

技术标签: Java  异常处理  FileNotFoundException  SSM框架  

 web.xml配置文件如下图所示:

但是老是报出以下的异常:

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [org.spring/applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [org.spring/applicationContext.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1366)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1454)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:295)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1379)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1537)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1547)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1526)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.io.FileNotFoundException: class path resource [org.spring/applicationContext.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 25 more
五月 07, 2014 7:10:08 下午 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: IOException parsing XML document from class path resource [org.spring/applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [org.spring/applicationContext.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1366)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1454)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:295)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1379)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1537)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1547)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1526)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.io.FileNotFoundException: class path resource [org.spring/applicationContext.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158) 

我使用idea创建的maven的pom.xml文件一开始在web项目的资源在打包部署时,为了防止mybatis的mapper文件被过滤掉,在pom文件的build节点下加入了如下代码:

但最终还是报出资源文件找不到的错误;

分析原因: 
maven默认扫描src/main/java中的文件而不理会src/main/resources中的xml文件,所以后来添加了resource节点,这样就将src/main/resources中的xml文件改变maven默认的扫描策略,防止造成src/main/resources下的配置文件打包丢失,具体的代码如下:

 <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>

 

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_42696130/article/details/81074317

智能推荐

c++实现文件传输之二:功能实现_c++ 枚举sockte 句柄-程序员宅基地

文章浏览阅读3.9k次。在上一篇中,我们以经介绍了程序的流程和框架,在本篇将详细讨论各个功能的实现主要包括1.获取磁盘信息2.获取目录信息3.获取文件信息4.运行指定文件5.删除指定文件6.删除指定目录7.创建指定目录8.上传下载文件9.获取远程文件图标获取磁盘信息磁盘信息可以用API GetDriveType来实现,它以路径名作为参数(如C:/)返回磁盘类型,其实例代码如下DWORD GetDriverProc(COM_c++ 枚举sockte 句柄

BMP转成C语言数组文件工具(用image2lcd代替bmp2h exe)_bmp转数组-程序员宅基地

文章浏览阅读1.7k次。BMP转成C语言数组文件工具(用image2lcd代替bmp2h exe)_bmp转数组

序( 2018年4-6月,进行geographiclib1。42)_geographiclib c#-程序员宅基地

文章浏览阅读975次。由于本公司代码使用SDK方式开发,看不到源码,只好学习开源项目了。要不将来就成为码农了。从sourceforge看到,GIS排名前三的有个geographiclib,属于GIS类库,这样正好系统地学习下。最低版本是1.42,所有代码统计(包括例子)文件数总行数代码行数空行行数注释行数注释百分比代码百分比275644403485_geographiclib c#

c++for循环实现九九乘法表_c++使用for循环编写程序,输出九九乘法表-程序员宅基地

文章浏览阅读3.7k次。#include<iostream>using namespace std;void main(){ //打印九九乘法表 for(int i=1;i<=9;i++)//打印行 { for(int j=1;j<=i;j++) { cout<<i<<"*"<<j<<"="<<i*j<<" "; } cout<<endl; } system(..._c++使用for循环编写程序,输出九九乘法表

2021-6-22:开发小而美的博客(设计与规范和实体类构建)_小而美的博客数据库设计-程序员宅基地

文章浏览阅读143次。2021-6-22:开发小而美的博客(设计与规范)文章目录2021-6-22:开发小而美的博客(设计与规范)实体类博客 Blog博客分类Type博客标签Tag博客评论Comment用户User_小而美的博客数据库设计

什么是跨站脚本 (XSS) 攻击?_跨站脚本攻击-程序员宅基地

文章浏览阅读1.8k次,点赞2次,收藏9次。这一次,教会xss攻击!!!!!!!_跨站脚本攻击

随便推点

花生壳5.0 for Linux使用教程_phddns5-程序员宅基地

文章浏览阅读3.7k次。注意:(1)当前5.0版本不支持使用内置帐号、不兼容3.0版本、不可直接从3.0升级到5.0,需卸载3.0后才可安装5.0,请3.0版本的用户按需升级。(2)在安装Linux 5.0前确认系统已安装好wget依赖包。CentOS:yum -y install wgetUbuntu:apt-get update (更新软件列表)、apt-get install wget (下载wget工具)、wget --version (查看下载安装成功wget版本)一、下载进入花生壳站点下载Linux _phddns5

孩子兄弟表示法家谱_孩子兄弟表示法族谱-程序员宅基地

文章浏览阅读2.5k次。#include #include #include #include const int MAXSIZE = 5000;const int NAME_LENGTH = 500;using namespace std;struct TreeNode{ char name[NAME_LENGTH];//定义一个字符数组,存放姓名 int level;//辈分_孩子兄弟表示法族谱

使用 RSA 算法进行加解密,签名和验签_rsa签名 online-程序员宅基地

文章浏览阅读995次。文章目录使用 RSA 算法进行加解密,签名和验签1、简介2、引入依赖3、生成公私钥对4、进行签名和验签5、进行加密和解密6、运行一下7、完整代码使用 RSA 算法进行加解密,签名和验签1、简介RSA是1977年由罗纳德·李维斯特(Ron Rivest)、阿迪·萨莫尔(Adi Shamir)和伦纳德·阿德曼(Leonard Adleman)一起提出的。当时他们三人都在麻省理工学院工作。RSA就是他们三人姓氏开头字母拼在一起组成的是一种非对称加密算法2、引入依赖 <depe_rsa签名 online

vue2.0中引入UEditor的一些坑。。。。-程序员宅基地

文章浏览阅读379次。开发后台系统的时候,富文本编辑器肯定是必不可少的,然后呢~在天朝当然要属百度编辑器(UEditor)最成熟了,功能全面,文档齐全(相对),ui优美(。。。,对于程序员来说)等等许多方面(MMP,还不是因为有中文文档和国人使用经验参考),所以使用百度编辑器就是不二之选了,早前再angular1的项目中使用过UE,主要是由后端配置好用,直接扔一个demo给我们,照着插入就OK了,现在呢,只能自己封装..._vue2 ueditor层级

测试Bugzilla中严重成度详细说明-程序员宅基地

文章浏览阅读700次。BUG严重级别解释规范目的:测试工程师在提交Bug时,为选择Bug的严重级别的依据。测试工程师在提交Bug时,需要选择该Bug的严重程度,不同的选项代表不同的严重程度,解释如下:Ø Blocker该Bug不仅造成本产品/项目异常,并且导致其他服务器、数据库、中间件、程序、操作系统等不能提供正常服务(包括客户端)。 Ø Critical该Bug影响两个..._bugzilla显示等级

tensorflow教程学习三TensorFlow运作方式入门-程序员宅基地

文章浏览阅读863次。讲解链接:http://wiki.jikexueyuan.com/project/tensorflow-zh/tutorials/mnist_tf.html"""Trains and Evaluates the MNIST network using a feed dictionary."""from __future__ import absolute_importfrom __future__tensorflow运作方式