找不到xml、找不到类

解决java.lang.ClassNotFoundException

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

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

导致上面3个问题的有以下两种情况

情况一

如果你是MAVEN项目,A项目依赖B项目的1.1.1版本的jar包。可是我用maven打包B项目的时候是打的2.2.2版本的jar包。

所以A项目找不到所依赖的B项目1.1.1版本,自然也找不到需要的class类。所以修改B项目pom.xml中的打包版本为1.1.1即可

    <groupId>com.xxx</groupId> 
    <artifactId>B-war</artifactId>
    <packaging>war</packaging>
    <version>1.1.1</version> 

 情况二

如果你是MAVEN项目,A依赖B,可能你根本没有在A的pom.xml里面配置B的依赖,如果没有,请在A的pom.xml里面添加B的依赖

<dependencies>
    <dependency>
        <groupId>com.xxx</groupId>
        <artifactId>B-web</artifactId>
    </dependency>
</dependencies>

 上面两种情况是我实际遇到,并解决的问题

 --------------------------------end--------------------------------

也许你是其他情况,如果你是MAVEN项目,也许你可以参考参考下面

<build>
        <resources>
            <resource>
                <directory>src/main/recourse</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

 

https://baike.baidu.com/item/%E6%9D%8E%E6%B4%9B%E5%85%8B/533202?fr=aladdin

原文地址:https://www.cnblogs.com/Alwaysbecoding/p/11595931.html