首页 > 其他分享 >class path resource [.xml] cannot be opened because it does not exist

class path resource [.xml] cannot be opened because it does not exist

时间:2023-09-20 16:00:12浏览次数:33  
标签:xml because resource exist path class

class path resource [bean1.xml] cannot be opened because it does not exist

错误重现

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

image-20230807151326126

public static void main(String[] args) {
        //解析beans.xml文件 , 生成管理相应的Bean对象
        ApplicationContext context = new ClassPathXmlApplicationContext("bean1.xml");
        //getBean : 参数即为spring配置文件中bean的id .
        Hello hello = (Hello) context.getBean("hello");
        System.out.println(hello.toString());
    }

错误原因

简单,就是明明xml在,但是找不到。

image-20230807151512224

解决方法

image-20230807152321288

这样即可!

image-20230807152348411

成功啦!

标签:xml,because,resource,exist,path,class
From: https://www.cnblogs.com/Lovi/p/17717574.html

相关文章

  • 解决pycharm报错:_jb_pytest_runner.py:7:....from pkg_resources import iter_entry_p
    遇到问题执行pytest用例出现警告D:\pycharm\PyCharm2020.1.5\plugins\python\helpers\pycharm_jb_pytest_runner.py:7:DeprecationWarning:pkg_resourcesisdeprecatedasanAPI.Seehttps://setuptools.pypa.io/en/latest/pkg_resources.htmlfrompkg_resourcesimport......
  • Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: com.fa
    报错:Handlerdispatchfailed;nestedexceptionisjava.lang.NoSuchMethodError:com.fasterxml.jackson.databind.ObjectMapper.canSerialize(Ljava/lang/Class;Ljava/util/concurrent/atomic/AtomicReference;)Zjar包冲突,找到对应的jar包删除......
  • java dom4j操作xml
    SAXReaderreader=newSAXReader();Documentdoc=reader.read(...);ListchildNodes=doc.selectNodes("//Config/Child/ChildNode");for(Objectobj:childNodes){NodechildNode=(Node)obj;Stringname=childNode.......
  • Resource文件夹(转)
    转自:#Assets-Unity为何不建议使用ResourcesFolder?-简书(jianshu.com)最近换项目,中间有了几天“间歇期”,正好可以抽空读一读这篇文章,读起来并不轻松,英语水平有限,尝试理解其中的含义概念,有些段落反反复复看了多次,在这里把笔记分享出来,这也是对知识的一次总结。初学Unity......
  • MyBatis中 Mapper.xml 文件
     resources目录下新建文件夹mapper(个人习惯全路径与Mapper类对应) <?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEmapperPUBLIC"-//mybatis.org//DTDMapper3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd......
  • 【MyAndroid】AndroidManifest.xml合并规则详解和注意事项
    APK或AndroidAppBundle文件只能包含一个AndroidManifest.xml文件,但AndroidStudio项目可以包含多个清单文件,这些清单文件由主源代码集、build变体和导入的库提供。因此,在构建应用时,Gradle构建系统会将所有清单文件合并成一个清单文件打包到应用中。清单合并工具遵循某些......
  • 关于使用LoadResource、EndUpdateResource的问题
    需要操作资源DLL中的资源,自作聪明的将其写成一个如下的类://---------------------------------------------------------------------------#ifndefUnit2H#defineUnit2H#include<windows.h>#include<assert.h>//-------------------------------------------------------......
  • WEB漏洞-XXE&XML之利用检测绕过全解
    XML内容: <?xmlversion="1.0"?> <!DOCTYPEa[ <!ENTITY%dSYSTEM“file:///etc/passwd”>%d; ]> <c>%d;</c> XML内容 <?xmlversion=’1.0’?> <!DOCTYPEa[ <!ENTITY%dSYSTEM“http://abc.com/evil.dt......
  • 关于getClass().getClassLoader().getResourceAsStream——转载自https://www.cnblogs
    关于getClass().getClassLoader().getResourceAsStreamInputStreamis=getClass().getClassLoader().getResourceAsStream("helloworld.properties");getClass():取得当前对象所属的Class对象getClassLoader():取得该Class对象的类装载器类装载器负责从Java字符文件将字符流读......
  • 计划任务导入xml
     https://superuser.com/questions/1031539/create-schedule-task-from-xml-file-by-batch-fileschtasks.exe/create/sNAMEOFCOMPUTER/ruDOMAIN\USER/rpPASSWORD/tnNAMEOFTASK'/XMLPATHTOXMLFILE ......