在Eclipse中不使用Maven创建src/main/java文件夹结构

时间:2023-01-15 21:32:02

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

在没有Maven的情况下,如何在Eclipse的默认web应用程序项目中创建src/main/java和src/test/java ?我当前的文件夹结构是

 TestApp
       -JavaResources
         - src  
           - com.mypackage
       -WebContent

8 个解决方案

#1


144  

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之前,您必须告诉Eclipse不要将src视为源文件夹。为此,右键单击src文件夹并选择build path ->从build path中删除。

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.

一旦完成此操作,src将出现在文件夹树的正常位置,因此您可以在其中创建主文件夹和java文件夹,并将现有的src/com移动到src/main/java/com。最后,右键单击新建的java文件夹,并选择build path ->作为源文件夹。

#2


9  

I have solved this issue by below steps:

我通过以下步骤解决了这个问题:

Right click the Maven Project -> Build Path -> Configure Build Path In Order and Export tab, you can see the message like '2 build path entries are missing' Now select 'JRE System Library' and 'Maven Dependencies' checkbox Click OK

右键单击Maven项目—>构建路径—>按顺序配置构建路径和Export选项卡,您可以看到“2构建路径条目缺失”和“现在选择”JRE系统库和“Maven依赖项”复选框单击OK

#3


4  

Open Properties > Java Build Path for the project. Select the Source tab and use Add Folders to add source folders.

为项目打开属性> Java构建路径。选择Source选项卡并使用Add Folders来添加源文件夹。

#4


2  

Remove the actual source folder definition in the build path and add a new source folder an name it src/main/java

在构建路径中删除实际的源文件夹定义,并添加一个新的源文件夹,名称为src/main/java

#5


1  

the problem will be solved by checking on 'JRE System Library' and 'Maven Dependencies' checkboxs Click OK. this is found in the project's 'build path option'

这个问题将通过检查“JRE系统库”和“Maven依赖项”复选框来解决。这可以在项目的“构建路径选项”中找到

#6


0  

在Eclipse中不使用Maven创建src/main/java文件夹结构

If you don't find the Included Path just add the path it will resolve.

如果您没有找到包含的路径,只需添加它将解析的路径。

#7


0  

If the package structure is setup as src.main.java.com.inventica, instead of com.inventica, that’s usually because under project properties > Java build path > Source, the source folder is setup as “src” instead of “src/main/java”. There’s no easy way to fix this, so remove “src” as a source folder and click ok. Now eclipse will show a folder hierarchy “src/main/java”. Browse to the “java” folder > right click > build path > use as source folder. After this you may have to fix the Eclipse .project and .classpath files to have it use Maven to manage dependencies, builds etc. Typically, you can copy this from a working project since there isn’t anything project specific here assuming you’re structured as a standard Maven project.

如果包结构设置为src.main.java.com.inventica,而不是com。这通常是因为在项目属性> Java构建路径>源时,源文件夹被设置为“src”而不是“src/main/ Java”。没有简单的方法来修复它,所以将“src”删除为源文件夹并单击ok。现在eclipse将显示一个文件夹层次结构“src/main/java”。浏览到“java”文件夹>右键单击>构建路径>作为源文件夹。在此之后,您可能需要修复Eclipse .project和.classpath文件,让它使用Maven来管理依赖项和构建等。通常,您可以从一个正在工作的项目中复制这个文件,因为这里没有任何特定的项目,假设您的结构是一个标准的Maven项目。

#8


0  

Simple solution would be create 'java' folder directly one the drive into src/main even before opening it in eclipse that way eclipse will not complain about the issue.

简单的解决方案是,在eclipse中打开“java”文件夹之前,直接在硬盘上创建一个src/main文件夹,这样eclipse就不会抱怨这个问题。

#1


144  

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之前,您必须告诉Eclipse不要将src视为源文件夹。为此,右键单击src文件夹并选择build path ->从build path中删除。

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.

一旦完成此操作,src将出现在文件夹树的正常位置,因此您可以在其中创建主文件夹和java文件夹,并将现有的src/com移动到src/main/java/com。最后,右键单击新建的java文件夹,并选择build path ->作为源文件夹。

#2


9  

I have solved this issue by below steps:

我通过以下步骤解决了这个问题:

Right click the Maven Project -> Build Path -> Configure Build Path In Order and Export tab, you can see the message like '2 build path entries are missing' Now select 'JRE System Library' and 'Maven Dependencies' checkbox Click OK

右键单击Maven项目—>构建路径—>按顺序配置构建路径和Export选项卡,您可以看到“2构建路径条目缺失”和“现在选择”JRE系统库和“Maven依赖项”复选框单击OK

#3


4  

Open Properties > Java Build Path for the project. Select the Source tab and use Add Folders to add source folders.

为项目打开属性> Java构建路径。选择Source选项卡并使用Add Folders来添加源文件夹。

#4


2  

Remove the actual source folder definition in the build path and add a new source folder an name it src/main/java

在构建路径中删除实际的源文件夹定义,并添加一个新的源文件夹,名称为src/main/java

#5


1  

the problem will be solved by checking on 'JRE System Library' and 'Maven Dependencies' checkboxs Click OK. this is found in the project's 'build path option'

这个问题将通过检查“JRE系统库”和“Maven依赖项”复选框来解决。这可以在项目的“构建路径选项”中找到

#6


0  

在Eclipse中不使用Maven创建src/main/java文件夹结构

If you don't find the Included Path just add the path it will resolve.

如果您没有找到包含的路径,只需添加它将解析的路径。

#7


0  

If the package structure is setup as src.main.java.com.inventica, instead of com.inventica, that’s usually because under project properties > Java build path > Source, the source folder is setup as “src” instead of “src/main/java”. There’s no easy way to fix this, so remove “src” as a source folder and click ok. Now eclipse will show a folder hierarchy “src/main/java”. Browse to the “java” folder > right click > build path > use as source folder. After this you may have to fix the Eclipse .project and .classpath files to have it use Maven to manage dependencies, builds etc. Typically, you can copy this from a working project since there isn’t anything project specific here assuming you’re structured as a standard Maven project.

如果包结构设置为src.main.java.com.inventica,而不是com。这通常是因为在项目属性> Java构建路径>源时,源文件夹被设置为“src”而不是“src/main/ Java”。没有简单的方法来修复它,所以将“src”删除为源文件夹并单击ok。现在eclipse将显示一个文件夹层次结构“src/main/java”。浏览到“java”文件夹>右键单击>构建路径>作为源文件夹。在此之后,您可能需要修复Eclipse .project和.classpath文件,让它使用Maven来管理依赖项和构建等。通常,您可以从一个正在工作的项目中复制这个文件,因为这里没有任何特定的项目,假设您的结构是一个标准的Maven项目。

#8


0  

Simple solution would be create 'java' folder directly one the drive into src/main even before opening it in eclipse that way eclipse will not complain about the issue.

简单的解决方案是,在eclipse中打开“java”文件夹之前,直接在硬盘上创建一个src/main文件夹,这样eclipse就不会抱怨这个问题。