Eclipse在我的Maven项目中未像我在其他地方看到的那样显示src/main/resources。

huangapple go评论77阅读模式
英文:

Eclipse doesn't show src/main/resources in my maven project the way I see it elsewhere

问题

我正在处理一个别人创建的 Maven 项目。在 Eclipse 的包资源管理器中,它的结构如下所示:

他们的项目名称
   src/main/java
   src/main/resources
   src/test/java
   src/test/resources
   JRE 系统库
   Maven 依赖项
   ...
   src
      main
      test
   pom.xml
   他们的项目名称.launch

我也在从头开始创建的一个 Maven 项目中工作。它的结构如下所示:

我的项目名称
   src/main/java
   src/test/java
   JRE 系统库
   Maven 依赖项
   src
      main
         resources
            ...
   pom.xml

换句话说,当我尝试创建 src/main/resources 目录时,它没有出现在我想要的位置,而是出现在了 src 文件夹中,而不是顶层显示。我是否错过了什么步骤?如果我从操作系统资源管理器查看工作区,我们的目录结构是相同的。

英文:

I am working on a maven project someone else created. The package explorer in eclipse looks like

their_project_name
   src/main/java
   src/main/resources
   src/test/java
   src/test/resources
   JRE System Library
   Maven Dependencies
   ...
   src
      main
      test
   pom.xml
   their_project_name.launch

I'm also working on a Maven project I started from scratch. Its structure looks like:

my_project_name
   src/main/java
   src/test/java
   JRE System Library
   Maven Dependencies
   src
      main
         resources
            ...
   pom.xml

In other words, when I tried to create the src/main/resources directory, it didn't show up in the explorer where I wanted it to go. It instead went in this src folder, instead of showing up at the top level. Is there a step I missed? If I look at the workspace from my OS explorer, our directory structures are the same.

答案1

得分: 2

你创建了一个 Folder 还是一个 Source Folder?正确的是 Source Folder,并且使用正确的名称,它应该显示在 src/main/java 旁边。

英文:

Did you create a Folder or a Source Folder ? The correct one is Source Folder, and with the correct name, it should show up next to the src/main/java.

答案2

得分: 1

解决方案

您需要将资源文件夹添加到类路径中。请按照以下步骤进行操作:

  1. 右键单击文件夹
  2. 将鼠标悬停在 Build Path
  3. 单击 Use as Source Folder

Eclipse在我的Maven项目中未像我在其他地方看到的那样显示src/main/resources。

> 那些顶级目录是源文件夹的“快捷方式”

英文:

Solution

You need to add the resources folder to your classpath. Please do the following

  1. Right click the folder
  2. Hover over Build Path
  3. Click Use as Source Folder

Eclipse在我的Maven项目中未像我在其他地方看到的那样显示src/main/resources。

> Those top level directories are source folder "short cuts"

huangapple
  • 本文由 发表于 2020年10月9日 22:20:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/64281891.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定