idea的maven項目運行出錯_java.io.FileNotFoundException: class path resource [spring/sprint-tx.xml] cannot be opened because it does not exist


前提: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>

 

記錄此次粗心造成的麻煩!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM