IOException parsing XML document from class path resource [applicationContent.xml]; nested exception
Spring报错问题:
IOException parsing XML document from class path resource [applicationContent.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContent.xml] cannot be opened because it does not exist
原代码如下
public class Main {public static void main(String[] args) {// HelloWord hello = new HelloWord();// hello.setName("atguigu");// hello.hello();//1.创建Spring的IOC容器对象ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContent.xml");//2.从IOC容器中获取Bean实例HelloWord helloWord = (HelloWord)ctx.getBean("helloWord");//调用hello方法helloWord.hello();}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 配置Bean --><bean id="helloWord" class="com.atguigu.spring.beans.HelloWord"><property name="name" value="Spring"></property></bean></beans>
项目层次截图:
在网上查找资料后发现,是applicationContent.xml文件位置问题,必须把spring的配置文件beans.xml或者applicationContext.xml放到系统根目录下,即项目层次为下图:
经修改过后,调试时不报错
IOException parsing XML document from class path resource [applicationContent.xml]; nested exception相关推荐
- 报错:IOException parsing XML document from class path resource [applicationContext.xml]; nested except
1.出现IOException parsing XML document from class path resource [applicationContext.xml]; nested excep ...
- IOException parsing XML document from class path resource [xxx.xml]
最近在idea导入项目的时候,加载xml文件失败,后台报了如下异常,xml文件没找到. org.springframework.beans.factory.BeanDefinitionStoreExc ...
- 【已解决】IOException parsing XML document from class path resource [xxx.xml]
报错异常 IOException parsing XML document from class path resource [xxx.xml]; nested exception is java.i ...
- 报错解决:IOException parsing XML document from class path resource [spring-mvc.xml]
今天在创建一个springmvc的项目的时候,我碰到了页面上的报错: IOException parsing XML document from class path resource [spring ...
- Line 2 in XML document from class path resource [applicationConfigMoNi.xml] is invalid; nested exce
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreExc ...
- SSM中maven导入jar的报错问题(Line 1 in XML document from class path resource [applicationContext.xml] is ...)
问题描述 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document f ...
- IOException parsing XML document from class path resource [applicationContext.xml]
今天在学习Spring框架时遇到了错误: 经过报错分析发现是applicationContext.xml文件位置放错了. 在本地测试时,applicationContext.xml文件应该放在src目 ...
- 【Spring5】Spring项目运行时报错:IOException parsing XML document from class path resource [bean.xml]
需要把bean.xml文件放在当前module的src文件夹下,而不能是其他的package下.
- parsing XML document from class path resource [applicationContext.xml]…
方法 1.可能是缺失了resource文件: 项目右键--Build Path--Configure Build Path----Java Build Path--source--Add Folder ...
最新文章
- 图片对服务器性能,关于适用base64对图片进行编码在服务器上性能的相关讨论
- 从业务视角看交互设计师的价值
- android sdk里的各目录作用
- 洛谷 P2163 [SHOI2007]园丁的烦恼 (离线sort,树状数组,解决三维偏序问题)
- dubbo报错Data length too large: 10710120处理,及服务提供者协议配置详细说明
- 还有更多REST技巧
- pat 乙级 1056 组合数的和(C++)
- python对印刷的用途_用Python式的方法来印刷价值
- 还有戏!尽管疫情严重,苹果公司仍可能4月推出iPhone 9
- 实现远程访问局域网内的多台电脑
- java中properties作用,Java中Properties的使用详解
- Excel对比条形图
- LA 4487 Exclusive-OR
- 句子迷网站 据说战争与和平很牛
- 光电式液位传感器和电容式液位传感器的区别
- 计算机显卡的安装步骤简约,自己组装电脑:显卡安装教程
- TIFF库的tif图片读写
- PHP将word文件转为图片预览
- 汇编语言学习笔记06——加减乘除和其他一些指令
- mysql免安装版安装教程