开发者

Issues with maven project running in eclipse, not recognized as Java project

I've imported an existing maven project into Eclipse. I tried to set up the configurations for a JUnit test, and my project wouldn't come up as a testable project. When I typed in the project name manually, I was given the message:

Specified project is not a java project

I've also noticed that when typing code and trying to call a method e.g. "System.out" a message pops up when I type the period, saying:

This compilation unit is not on the build path of a java project

Additionally, there are no actions available when I right click the project and navigate to Build Path.

Having looked this up on here and elsewhere, I've followed the following pieces of advice, without success:

I've verified the existence of .project and .classpath files

I've looked in the .project file and verified the inclusion of a javanature

I've run mvn eclipse:eclipse

I've right-clicked the project in the PackageExplorer > Maven > Update Project Configuration

Java is not listed as a project facet but I'm not sure I should mess with that because I've tried clicking that, and that caused the entire project to be filled with errors (I think related to build path, but I can't quite remember). Removing Java as a facet didn't get rid of the errors and I had to re-import the project from scratch.

Sorry if any of this is vague, and thanks for the help.

I'm using m2eclipse开发者_开发知识库.

EDIT: Problem was solved simply by deleting the project from my workspace, deleting all .project, .classpath files and .settings folders, and re-importing. I don't know why it didn't work the first time.


I've run mvn eclipse:eclipse
I've right-clicked the project in the PackageExplorer > Maven > Update Project Configuration

Those two should be mutually exclusive. Either you manage a project from the outside using eclipse:eclipse or from the inside using m2eclipse. Don't mix them.

Possible cause of the problem:

The packaging is POM (perhaps this is the root of a multi-module project, in which case you have to import the module projects). m2eclipse doesn't add the Java nature to POM projects (nor does eclipse:eclipse, btw)


Make sure if you have M2 plugin in Eclipse, you have Maven 2.7 above installed in your system.

After that run mvn eclipse:clean then mvn eclipse:eclipse.

.classpath and .project will be created in your project folders. Everything should be fine.


pls follow the below website.. Right click on the project, go to Properties, then select Project Facets. this will convert it to a java/dynamic web projects for the use.


I'm using Version: Indigo Service Release 2 Build id: 20120216-1857

I also found that after I installed the Maven plugin that 'Project Explorer' - Right click on 'my project' did not list option "Maven" or "configure".

On reading the above, I tried doing the same on "Package Explorer" and to my surprise it worked. And now 'Project Explorer' works too!


I had what seemed like the same issue. In my case, I was checking out a Maven project that contained multiple (parent/child) poms.

If the highest level Maven project within your repository/branch simply manages child poms, it may not contain Java definitions at all. You will need to open these child projects as an independent project within Eclipse.

You can do this by right clicking on your project -> Import -> Maven -> Existing Maven Projects -> then select child project you are wanting to change.


Install m2e and subclipse from the Eclipse Marketplace depending on what version of Eclipse you have. Then:

  1. Open Eclipse go to Window > Open Perspective > Other... > SVN Repository Exploring.
  2. Add your svn url to SVN repository/code base.
  3. Select a project. Right Click and select Checkout.
  4. Assuming your project has a pom.xml, switch back to your Java perspective, select the project that was just imported, right click and select Configure > Convert to Maven Project.

It should now be recognized as both a Maven and a Java project (Maven and Java natures will have been added to the Eclipse .project file)


Problem was solved simply by deleting the project from my workspace, deleting all .project, .classpath files and .settings folders, and re-importing. I don't know why it didn't work the first time. Thanks for the help, everyone.


right click project --> properties --> maven --> lifecycle mapping --> check (skip maven compiler plugin) click ok now the build path appears . nw do the necessary changes


I got stuck in similar situation but I realized that since I am trying to change in the parent collection you cannot find eclipse intellisense due to the fact that it is just holding the projects. Try working on exclusive project created by maven.


Check the packaging tag in the pom.xml file.

It worked when I changed pom.xml to use:

<packaging>jar</packaging>


Make sure that POM doesn't have any error, Eclipse detecting the project types based on the initial build (automatically or manual).


The Project nature is decided by the .project file in Eclipse, which also dictates to Eclipse about the Parent Source Code, and Test Folders.

Update/Modify the .project file as follows, using which We retain the Maven Compatibility and Java Nature of the Project.

.project.xml under the Eclipse Project folder

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
        <name>java-cgdk-en</name>
        <comment></comment>
        <projects>
        </projects>
        <buildSpec>
                <buildCommand>
                        <name>org.eclipse.jdt.core.javabuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
        </buildSpec>  
        <natures>
                <nature>org.eclipse.jdt.core.javanature</nature>
        </natures>
</projectDescription>


With Eclipse 2022-06 (4.24.0), none of the above worked for me. However, this did:

https://www.youtube.com/watch?v=aF0xP9SXcrE - How to resolve Child module not recognized as maven project

Hope this helps.


try to clean your eclipse

eclipse.exe -clean

if it's not work for you try to install a new eclipse and imposrt the same project

Update :

No need to install a new Eclipse just revert your vm args in eclipse.ini file if you already change it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜