导出属性隐藏xml

时间:2017-09-26 14:20:00

标签: java spring maven

在我的maven项目中,我需要读取其他项目中的属性,因此我使用资源导出它们并在我的项目中读取它们

<resources>
        <resource>
            <directory>src/main/resources/config</directory>
            <filtering>false</filtering>
            <includes>
                <include>**/*</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.*</include>
            </includes>
            <excludes>
                <exclude>**/*.class</exclude>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>

这是在包含资源的项目内的pom.xml中的构建,现在在sr / main / resources / spring下的该项目中我有一个xml文件定义了我的bean,在我添加资源后导出了属性这个xml文件&#34;找不到&#34;,我在运行maven build时遇到这个异常

 used by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring/my-beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/my-beans.xml] cannot be opened because it does not exist
Caused by: java.io.FileNotFoundException: class path resource [spring/my-beans.xml] cannot be opened because it does not exist

如果我删除了资源,则不会出现异常,任何人之前都会遇到此问题,或者知道这种行为背后的原因是什么?

1 个答案:

答案 0 :(得分:0)

您是如何尝试加载sprig bean xml的?看起来你在加载上下文时缺少/。它应该是/spring/my-beans.xml