idea的maven项目运行出错_java.io.FileNotFoundException: class path resource [spring/sprint-tx.xml] cannot be...

前提:idea  maven  ssm

错误信息如下:

严重: 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 [spring/sprint-tx.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/sprint-tx.xml] cannot be opened because it does not exist
   ...省略
Caused by: java.io.FileNotFoundException: class path resource [spring/sprint-tx.xml] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
    ... 21 more

一直报 class path resource [spring/sprint-tx.xml]不存在!而且resource目录的文件加载不到target目录下的classes文件夹里

文件位置如下:

pom.xml文件配置了对resource文件 过滤

 

 

<!--配置Maven 对resource文件 过滤 -->
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>*</include>
          <include>*/*</include>
        </includes>
        <filtering>true</filtering>
      </resource>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.xml</include>
        </includes>
        <filtering>true</filtering>
      </resource>
    </resources>

 

排查了好久,在网上也见其他人也出现了同种情况--》虽然配置了resources过滤,但是就是加载不到classes里面

、、、

直到又一次的排查中,瞄到了创建的目录,resource   ???  不是 resources

idea的maven项目默认的加载目录是 resources, pom.xml配置的也是<directory>src/main/resources</directory>

 

记录此次粗心造成的麻烦!

 

转载于:https://www.cnblogs.com/sunchunmei/p/11431595.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值