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

荒凉一梦 提交于 2019-12-02 18:44:31

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)

Zeta

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!

William

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!