imported maven project does not appear as java pro

2019-03-15 00:00发布

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

13条回答
疯言疯语
2楼-- · 2019-03-15 00:18

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

This solution worked for me

查看更多
劫难
3楼-- · 2019-03-15 00:19

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.

查看更多
SAY GOODBYE
4楼-- · 2019-03-15 00:20

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.

查看更多
来,给爷笑一个
5楼-- · 2019-03-15 00:22

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

查看更多
混吃等死
6楼-- · 2019-03-15 00:23

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.

查看更多
Rolldiameter
7楼-- · 2019-03-15 00:24

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.

查看更多
登录 后发表回答