Eclipse file search finds the same file multiple times

后端 未结 11 1285
生来不讨喜
生来不讨喜 2020-12-23 20:22

In Eclipse I have two maven projects A and B, where A is a parent for B. The directory structure is the following:

A/pom.xml
A/B/pom.xml
A/B/...
相关标签:
11条回答
  • 2020-12-23 20:59

    Windows - Preferences - Maven - Hide folders of physically nested modules

    0 讨论(0)
  • 2020-12-23 21:00

    In an open resource window (cntrl+shift+R), click on the arrow on top-right and check "Filter Duplicated Resources". This worked for me.

    0 讨论(0)
  • 2020-12-23 21:00

    I agree with Damon Horrell. Go to Windows - Preferences - Maven - Hide folders of physically nested modules (make sure the checkbox is checked).

    Note: Make sure to re-import the maven project into eclipse to see the changes.

    0 讨论(0)
  • 2020-12-23 21:03

    There is an ancient bug which requests Eclipse to support nested projects. Opened 2008, won't happen soon, I guess.

    Since Eclipse doesn't support Maven's default nested module layout, you have to import each module individually which doesn't confuse Eclipse but it can confuse you as you can see in the search results. Similar things happen when you start to save launch configs in a module.

    There are several possible solutions:

    1. Get used to ignoring half the search results. Takes some discipline but no magic.

    2. Make sure your root project doesn't contain anything important that you might want to open from Eclipse (i.e. move the parent POM to a new module which must be a child of the root project). Now you can close the root project.

      Takes some discipline where to put things in your project and it's clumsy when you have to add new modules.

    3. Use the flat multi-module approach. This is an extension to #2, it looks odd and there might be plugins that are offended by that. So if you use a lot of nonstandard plugins, you should check whether they like the new layout.

    0 讨论(0)
  • 2020-12-23 21:04

    Within the parent project, child ones were already visually hidden in my case, but still found through search and Ctrl-click links.

    I solved this by using Resource filters:

    1. Right-click (parent) project > Properties > Resource > Resource Filters
    2. Click Add Filter..., select Applies to -> Folders and enter one child project's folder name, click OK
    3. Repeat 2. for all child project folders

    By the end, you should have something like this:

    0 讨论(0)
  • 2020-12-23 21:06

    I had similar problem.

    My solution for this problem was

    1. Create eclipse "working set" of projects to search
    2. Set this working set as option into search dialog
    3. Search in it

    0 讨论(0)
提交回复
热议问题