Kevin Rave
Kevin Rave

Reputation: 14426

imported maven project does not appear as java project. Shows folders

I checked out the existing project source code from SVN to a folder in my system. Then I opened eclipse. Import Project-> Existing Maven Project.

It imported without issues. However, Project Explorer shows it as just folders instead of packages. (Like when we create a package and then add classes to it, it shows a different icon for package root). I opened Navigator and Package Explorer as well. But they are showing them as folders as well.

I tried:

mvn eclipse:clean
mvn eclipse:eclipse

on the root of the project. But it did not help.

Can anyone help on this one?

My folder structure:

ecs->
     ecs-ejb->
        src/java/main/com/xxx
        pom.xml
     ecs->ear->
        src/java/main/com/xxx
        pom.xml
     pom.xml

Upvotes: 22

Views: 83135

Answers (16)

Marky
Marky

Reputation: 1

reimport the same project as maven. Click on "Show other specialized import wizards', then use maven.

Upvotes: 0

dynamo
dynamo

Reputation: 126

You just need to change the nature of the project.

For MAC->

-> Right click on project
-> Properties -> Check Project Natures
-> Then add or remove accordingly if you are having a maven project then add Maven, add Java

Upvotes: 2

pk_25
pk_25

Reputation: 1

Adding projects to working sets should help

try it -> right click the project -> Maven -> Assign Working Sets... -> Add projects to working sets

Upvotes: 0

Suresh Laveti
Suresh Laveti

Reputation: 1

Here is my solution please close the Project Explorer at the left top and open again. (or) 1). Right Click on your miscellaneous project and choose project Explorer if available.

Upvotes: 0

Chocolim
Chocolim

Reputation: 56

I got it working using Proyect --> Properties --> Project Facets

In my case was a web project so I checked Java and Dynamic Web Module

Upvotes: 1

Ram
Ram

Reputation: 1591

Instead of importing as Existing Maven Project, follow below steps
I assume that your folder has pom.xml, src/main and src/test.

Step 1: Right click > Create New > Java Project > Chose the project folder has pom.xml
Step 2: Right Click on Project > Configure > Convert to Maven project

Upvotes: 1

Cathy
Cathy

Reputation: 67

Check and make sure you have eclipse pointing at a Java JDK directory instead of a Java JRE directory.

I had just installed eclipse and only the JRE was in the settings. I added the JDK path, changed it to the default and clicked on Maven -> Update project. Then the packages appeared in Package Explorer.

The hint that helped me figure this out is that when I tried to use the refactor to rename a class, it wouldn't do it, complaining that it wasn't a JDK.

Upvotes: 1

Swarit Agarwal
Swarit Agarwal

Reputation: 2648

Possibility is Module doesn't have .classpath.

Kindly right click on Module and Change Project fact as Java.

else

If you are using command Prompt. 1. mvn eclipse:clean 2. mvn eclipse:eclipse

else

Delete Project from Eclipse don't delete content from disk. remove .classpath and .project

Re-import as maven existing Project

Upvotes: 8

user5562505
user5562505

Reputation: 21

Right Click->Maven->Update Project.

Above works perfectly fine for Eclipse Juno and solves the problem.

Upvotes: 2

abhihello123
abhihello123

Reputation: 1728

Delete the metadata folder. Checkout again but select "Checkout as a project configured using the New Project Wizard" instead of "Checkout as a project in the workspace". Then a New Project wizard will open, type maven there and select "Checkout Maven Projects from SCM" preferably or "Maven Project". It should work. Remember this step should be performed for Maven Projects only. For normal Projects just select Java Project or whatever relevant type Eclipse project it is.

Upvotes: 1

user2772212
user2772212

Reputation: 11

I also faced a similar issue. I resolved it by downloading the correct apache maven plugins in the maven repository org / apache/ Maven/ plugins. IN my case, everything was working fine earlier and I had deleted .m2 repository completely. After that I started getting these issues with same iDE and newer IDE versions as well. The pom.xml showed error related to lifecycle mappings. On downloading the correct plugin, the workspace worked fine.

Upvotes: 1

prateek mehta
prateek mehta

Reputation: 171

Right click the project->Configure->Convert to Faceted Form

This solution worked for me

Upvotes: 17

Junior
Junior

Reputation: 13

I had the same problem. I tried a lot of things that I read on internet but the only way that I found to solve my problem was exclude all of my workspace files (.metadata folder) and create another one.

After that, I imported a existing maven project and all my problems are gone.

Upvotes: 1

Lucas
Lucas

Reputation: 14949

Try to:

  1. Right click the project->Configure->Convert to Maven Project

---- Edit ----

If this doesnt work, it is likely that someone checked in their environment files into your SVN. If they checked in:

  • .project
  • .classpath
  • .settings/

They could be conflicting with your environment (different settings/plugins/versions of eclipse...). Try dropping your project, deleting the folder/files, then remove these files from SVN, and repeat your initial process. All of these files/folders will get generated during the import to eclipse.

---- Edit 2 ----

Per your recent edit to the question, you have a multi-module project. If you only did this on the parent project, then there is no source folder. So you wouldn't see it. You should:

  1. File->Import...
  2. Choose Existing Maven Projects, Next
  3. Set the Root Directory to ecs/ecs-ejb, Finish
  4. Repeat for all other modules.

In eclipse, each module of a multi-module maven project needs its own eclipse project.

Upvotes: 21

James Dunn
James Dunn

Reputation: 8274

Right click the project, then click Configure -> Convert to Maven Project. If the packages still display as ordinary folders, then right click on the folder one level up (the one that is supposed to be the source folder), then click Build Path -> Use as a source folder.

Upvotes: 0

DairyLea
DairyLea

Reputation: 837

Try right click on project, Maven->Update Project... (or similar, the link name changes depending on version)

This works for me when adding new folders, but I have not encountered the problem when importing a project.

Upvotes: 1

Related Questions