Eclipse Maven showing multiple paths for the same

2020-02-09 08:37发布

Is there any setting in Eclipse to show only the Maven project where the file resides?

I have different Maven projects which are modules of a parent Maven project:

projParent
   |-projWeb
   |-projModel
   |-projServices
   |-...

If I look for a file using "Open Resource" (using Ctrl + Shift + r) in Eclipse, it appears in many projects (E.g.: in projParent and in projWeb).

Is there any way to show only relevant folder where that file is actually resided in?

3条回答
smile是对你的礼貌
2楼-- · 2020-02-09 09:19

Try defining a Working Set that includes only the modules in which you want to search and then use that Working Set in the search.

EDIT

Actually I tried it and it just works perfectly by default in eclipse 4.3 (Kepler), only one result is returned for nested projects.

Anyway, here's how to use working set in open resource (the example is not of a resource in a nested module as in this case Kepler don't show duplicate results; so the example is just of two different resources baring the same name in two different modules):

(1) Hit the ctrl+shift+R keys. I searched for a resource called pom.xml. You can see two results:

open resource no working set

(2) Press the little downward-pointing arrow on the top right of the window and choose Select Working Set...:

open resource select working set

(3) Check the radio button of Selected Working Sets and check the desired projects (in your case the leaf projects):

enter image description here

(4) And voila, Open Resource returns only one result:

open resource after working set is selected

查看更多
Explosion°爆炸
3楼-- · 2020-02-09 09:21

I just had the same issue and what worked for me was to select Filter Duplicated Resources in the Open Resource dialog:

Open menu Enable filter

Another (unrelated) useful feature is to hide submodule-folders from the parent-project in the package explorer.
This can be done by using the Maven modules filter in the menu of the package explorer:
Enable maven modules filter

Tested with Eclipse 2019-06 (4.12.0)

查看更多
Luminary・发光体
4楼-- · 2020-02-09 09:40

You are probably talking about a kind of duplication between parent project and its sub-modules. In the latest version of Eclipse (from 3.6 maybe and sure from 3.7) there is a new option

Menu Windows >

Item Preferences >

    Tree item Maven >

       Option : Hide folders of physically nested modules

This would not work on a existing project. You must delete them (logically) and re-import them

查看更多
登录 后发表回答