在没有 Maven 的情况下在 Eclipse 中创建 src/main/java 文件夹结构 [英] Creating a src/main/java folder structure in Eclipse without Maven
问题描述
如何在没有 Maven 的情况下在 Eclipse 的默认 Web 应用程序项目中创建 src/main/java
和 src/test/java
?我当前的文件夹结构是
How do I create the src/main/java
and src/test/java
in my default web application project in Eclipse without Maven? My current folder structure is
TestApp
├── JavaResources
│ └── src
│ └── com.mypackage
└── WebContent
推荐答案
正如你所发现的,你不能在另一个源文件夹中拥有一个源文件夹,所以在你可以创建 src/main/java
您必须告诉 Eclipse 不要将 src
视为源文件夹.为此,请右键单击 src
文件夹并选择构建路径 -> 从构建路径中删除.
As you've discovered, you can't have a source folder inside another source folder, so before you can create src/main/java
you have to tell Eclipse not to treat src
as a source folder. To do this, right click on the src
folder and select build path -> remove from build path.
完成此操作后,src
将出现在文件夹树中的正常位置,因此您可以创建 main
和 java
文件夹在它下面,将现有的 src/com
移动到 src/main/java/com
.最后右击新建的java
文件夹,选择构建路径->用作源文件夹.
Once you have done this src
will appear in the folder tree in its normal place, so you can create the main
and java
folders under it, and move the existing src/com
to src/main/java/com
. Finally right-click the newly-created java
folder and select build path -> use as source folder.
这篇关于在没有 Maven 的情况下在 Eclipse 中创建 src/main/java 文件夹结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!