“源文件夹不是Java项目”eclipse中的错误。

时间:2021-11-12 10:38:44

I am trying to import maven project into eclipse 4.2 version.Its not importing the project properly. Its giving me error "Source folder is not a Java project" while I am trying to create a new call in it. Even ctrl+mouse click is also not working. I don't understand the problem. Even when I right click on project and select build path it shows me no action available. Anyone face the same issue

我正在尝试将maven项目导入eclipse 4.2版本。它没有正确地导入项目。它给我的错误“源文件夹不是Java项目”,而我正在尝试创建一个新的调用。甚至ctrl+鼠标点击也不起作用。我不理解这个问题。即使我右键单击项目并选择build path,它也显示我没有可用的操作。任何人都面临同样的问题。

7 个解决方案

#1


54  

In the maven project directory try

在maven项目目录中尝试。

mvn eclipse:eclipse

that may do the trick.

这可能会奏效。

#2


28  

I ran into the same issue and fixed it by converting my project to faceted form.

我遇到了同样的问题,并通过将我的项目转换成多方面的形式来解决它。

Right click your project > Properties > Project Facets > Convert to Faceted Form, and select Java.

右击项目>属性>项目facet >转换成面形式,并选择Java。

“源文件夹不是Java项目”eclipse中的错误。

#3


4  

Either turn your project into Eclipse project, using mvn eclipse:eclipse, or install Maven Integration for Eclipse plugins, like m2eclipse, and import project as a Maven project.

可以使用mvn Eclipse: Eclipse,或者为Eclipse插件安装Maven集成,比如m2eclipse,或者将项目作为Maven项目导入。

#4


4  

I got the same error in a slightly different context (Indigo with m2eclipse):

我在稍微不同的上下文中得到了相同的错误(Indigo与m2eclipse):

I imported a multi-module (1 jar module and 1 war module) maven project into Eclipse. Everything worked fine (clean, install OK) until I tried to add a new class to one of the modules and got the "Source Folder is not a Java project" error.

我在Eclipse中导入了一个多模块(1个jar模块和一个war模块)maven项目。在我尝试向其中一个模块添加一个新类并得到“源文件夹不是Java项目”错误之前,一切都很正常(clean, install OK)。

I solved this by opening the properties on the parent project and selecting the following Project Facets:
Java
Dynamic Web Module

我通过在父项目上打开属性并选择以下项目方面来解决这个问题:Java动态Web模块。

This solved the problem. My guess is that, because the parent project for a multi-module project has pom packaging (<packaging>pom</packaging>), Eclipse doesn't know what kind of projects the parent project encloses (i.e. if the packaging were jar, it would know that it's a java project; if the packaging were war, it would know that it's a static or dynamic web module, etc.)

这解决了这个问题。我的猜测是,由于一个多模块项目的父项目有pom包装( <包装> pom),Eclipse不知道父项目包含哪些项目(例如,如果包装是jar,它将知道它是一个java项目;如果包装是战争,它将知道它是一个静态或动态的web模块,等等。

This is just my guess, but the fix worked for me, and it makes sense.

这只是我的猜测,但修复工作对我来说是有用的,这是有意义的。

#5


3  

I had the same problem... But you just need to update "source Folder" to correct source "src/main/java" from whatever mentioned in the pop up:

我有同样的问题……但是你只需要更新“源文件夹”来正确地从弹出的内容中找到“src/main/java”来源:

[“源文件夹不是Java项目”eclipse中的错误。]

[]

#6


1  

for those who already see java selected, uncheck and check it again. select apply to override the existing setttings. finally it works !

对于那些已经看到java选择的人,取消检查并再次检查。选择apply以覆盖现有的设置。最后它工作!

Right click your project > Properties > Project Facets > Convert to Faceted Form, and select Java

右击项目>属性>项目facet >转换成面形式,并选择Java。

#7


1  

mvn eclipse:eclipse will resolve this problem. convert to maven project.

mvn eclipse:eclipse将解决这个问题。转换到maven项目。

#1


54  

In the maven project directory try

在maven项目目录中尝试。

mvn eclipse:eclipse

that may do the trick.

这可能会奏效。

#2


28  

I ran into the same issue and fixed it by converting my project to faceted form.

我遇到了同样的问题,并通过将我的项目转换成多方面的形式来解决它。

Right click your project > Properties > Project Facets > Convert to Faceted Form, and select Java.

右击项目>属性>项目facet >转换成面形式,并选择Java。

“源文件夹不是Java项目”eclipse中的错误。

#3


4  

Either turn your project into Eclipse project, using mvn eclipse:eclipse, or install Maven Integration for Eclipse plugins, like m2eclipse, and import project as a Maven project.

可以使用mvn Eclipse: Eclipse,或者为Eclipse插件安装Maven集成,比如m2eclipse,或者将项目作为Maven项目导入。

#4


4  

I got the same error in a slightly different context (Indigo with m2eclipse):

我在稍微不同的上下文中得到了相同的错误(Indigo与m2eclipse):

I imported a multi-module (1 jar module and 1 war module) maven project into Eclipse. Everything worked fine (clean, install OK) until I tried to add a new class to one of the modules and got the "Source Folder is not a Java project" error.

我在Eclipse中导入了一个多模块(1个jar模块和一个war模块)maven项目。在我尝试向其中一个模块添加一个新类并得到“源文件夹不是Java项目”错误之前,一切都很正常(clean, install OK)。

I solved this by opening the properties on the parent project and selecting the following Project Facets:
Java
Dynamic Web Module

我通过在父项目上打开属性并选择以下项目方面来解决这个问题:Java动态Web模块。

This solved the problem. My guess is that, because the parent project for a multi-module project has pom packaging (<packaging>pom</packaging>), Eclipse doesn't know what kind of projects the parent project encloses (i.e. if the packaging were jar, it would know that it's a java project; if the packaging were war, it would know that it's a static or dynamic web module, etc.)

这解决了这个问题。我的猜测是,由于一个多模块项目的父项目有pom包装( <包装> pom),Eclipse不知道父项目包含哪些项目(例如,如果包装是jar,它将知道它是一个java项目;如果包装是战争,它将知道它是一个静态或动态的web模块,等等。

This is just my guess, but the fix worked for me, and it makes sense.

这只是我的猜测,但修复工作对我来说是有用的,这是有意义的。

#5


3  

I had the same problem... But you just need to update "source Folder" to correct source "src/main/java" from whatever mentioned in the pop up:

我有同样的问题……但是你只需要更新“源文件夹”来正确地从弹出的内容中找到“src/main/java”来源:

[“源文件夹不是Java项目”eclipse中的错误。]

[]

#6


1  

for those who already see java selected, uncheck and check it again. select apply to override the existing setttings. finally it works !

对于那些已经看到java选择的人,取消检查并再次检查。选择apply以覆盖现有的设置。最后它工作!

Right click your project > Properties > Project Facets > Convert to Faceted Form, and select Java

右击项目>属性>项目facet >转换成面形式,并选择Java。

#7


1  

mvn eclipse:eclipse will resolve this problem. convert to maven project.

mvn eclipse:eclipse将解决这个问题。转换到maven项目。