eclipse 资源文件夹不在类路径上

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14791045/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:58:44  来源:igfitidea点击:

Resource folder not on classpath

eclipsemavenlog4j2

提问by Royi Freifeld

My previous questionabout a problem I had, led me to numerous file path changing in order to come up with an answerthat caused Maven not not to work properly (apparently Maven is not fond of sub-source-folders).
I changed the project folders to adhere Maven's standard directory layoutand put log4j2.xml under src/main/resources/META-INFand the problem returned.
For some reason a Folder in eclipse is not on classpath.

之前关于我遇到的一个问题的问题导致我更改了许多文件路径,以便找到导致 Maven 无法正常工作的答案(显然 Maven 不喜欢子源文件夹)。
我更改了项目文件夹以遵守Maven 的标准目录布局,并将 log4j2.xml 放在src/main/resources/META-INF 下,问题返回。
出于某种原因,eclipse 中的文件夹不在类路径上。

How do I make it work?

我如何使它工作?

EDIT:
I'm using the latest m2e to manage project's build and packages.
The project (is currently) consists of several sub-projects.
The parent pom defines the different modules and Java's compiler version. The pom of the module containing the META-INF folder, states several dependencies, nothing more.

编辑:
我使用最新的 m2e 来管理项目的构建和包。
该项目(目前)由几个子项目组成。
父 pom 定义了不同的模块和 Java 的编译器版本。包含 META-INF 文件夹的模块的 pom 说明了几个依赖项,仅此而已。

回答by Simulant

rightclick on your project -> add source folder -> select your resourcefolder. done.

右键单击您的项目 -> 添加源文件夹 -> 选择您的资源文件夹。完毕。

回答by JohnEye

The solution in Eclipse Oxygen.3a is to right-click on the folder -> Build Path -> Use as Source Folder.

Eclipse Oxygen.3a 中的解决方法是右键单击文件夹-> 构建路径-> 用作源文件夹。