java.io.FileNotFoundException: class path resource ..cannot be opened because it does not exist

java.io.FileNotFoundException: class path resource ..cannot be opened because it does not exist
异常如下:
java.io.FileNotFoundException: class path resource [com/jxust/zjh/model/Account.hbm.xml] cannot be opened because it does not exist

在spring中我这样配置<property name="mappingResources">
<list> <value>com/jxust/zjh/model/Account.hbm.xml</value>
</list>
</property>
就报上述错误,Account.hbm.xml确实在此目录下。
但是,我改成这样就运行正常,
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/jxust/zjh/model/</value>
</list>
</property>

解决方案:
1.路径问题,,,,,,直接将配置文件搞到src下面.....因为myeclipse默认会去src下找

最简单的方法还是老老实实把xml放在src下方便。

或者建立config时建立成source folder,,,,就相当于是classpath了

2.此时去查看tomcat中的web-inf下的classes文件夹,查看上面报错的差找不到beans文件是否存在于tomcat中....如果不存在,,,,说明原因在这里

此时需要将tomcat中部署的项目删掉.然后在myeclipse中的项目工程clean一下,然后重新部署,会发现所有文件都部署到了tomcat中,项目完美运行.

  

时间: 2024-08-27 10:11:49

java.io.FileNotFoundException: class path resource ..cannot be opened because it does not exist的相关文章

Caused by: java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be ope

1.错误描述 java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99) at org.springframework.test.context.DefaultTestContext.

cxf(3.1.1) 异常Caused by: java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml]

Caused by: java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml] cannot be opened because it does not exist用的最新版本,这个版本中 cxf-extension-soap.xml 不需要了直接在配置文件中删除即可 现在只需要引两个文件 <import resource="classpath:META-INF/cxf/

java.io.FileNotFoundException: class path resource [XXXXX.xml] cannot be opened

java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exit. 在用maven管理的spring项目中做单元测试时候,加载不了spring的配置文件.出现该问题的原因是,用maven创建的项目,必须把spring的配置文件beans.xml或者applicationContext.xml放到系统根目录下,做单元测试时候用 ApplicationCon

解决CXF的java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml] cannot be opened because it does not exist

以下是错误信息 九月 25, 2017 8:22:04 下午 org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh 信息: Refreshing Root WebApplicationContext: startup date [Mon Sep 25 20:22:04 CST 2017]; root of context hierarchy 九月 25, 2017 8:22:04 下午 or

nested exception is java.io.FileNotFoundException: class path resource [spring/spring-datasource-mog

spring单元测试时发现的问题: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring/spring-datasource-mogon.xml]; nested exception is java.io.FileNotFoundException: class path resource [

parsing XML document from class path resource [applicationtext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationtext.xml] cannot be opened because it does not e

控制台异常: parsing XML document from class path resource [applicationtext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationtext.xml] cannot be opened because it does not exist 报错原因是 xml名字可能写错了 原文地址:https://www.cnbl

解决 java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

前几天好好运行的web项目突然跑不起来了 报这个错误 2019-09-16 19:18:29 [ RMI TCP Connection(3)-127.0.0.1:357 ] - [ ERROR ] Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource

Caused by: java.io.FileNotFoundException: class path resource [mappers/*.xml] cannot be opened because it does not exist

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsa

java.io.FileNotFoundException: [WEB-INF/spring-servlet.xml] cannot be opened because it does not exist

今天启动web 项目出现错误提示: java.io.FileNotFoundException: [WEB-INF/spring-servlet.xml] cannot be opened because it does not exist 没有找到问题原因: resource目录是存在:spring-servlet.xml 配置文件