You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Eclipse中创建Maven风格目录,如何隐藏Package Explorer中的src根目录

How to Hide the Root src Directory in Eclipse for Maven-Style Projects

Hey there! I totally get it—having that extra root src directory cluttering up your Package Explorer when you’ve set up your Maven-style src/main and src/test folders is super annoying. Here are a few solid ways to hide it cleanly:

Method 1: Filter the Root src Folder Directly

This is the quickest fix if you just want to hide that one folder without changing your project structure:

  • Open the Package Explorer, then click the tiny dropdown arrow (View Menu) in the top-right corner of the panel.
  • Select Filters... from the menu.
  • In the Filters window, switch to the Resource tab.
  • Click the Add... button, navigate to your project’s root src folder, select it, and hit OK.
  • Back in the Filters window, check the box next to the src folder you just added, then click OK. The folder will disappear from your Package Explorer immediately.

If you haven’t already, turning your project into a proper Maven project will not only hide the root src but also automate a lot of build path and directory management:

  • Right-click your project in Package Explorer > Configure > Convert to Maven Project.
  • Fill in the required fields (Group Id, Artifact Id, Version) in the popup, then click Finish.
  • Once converted, Eclipse will automatically recognize the Maven directory structure. Switch your Package Explorer to Hierarchical presentation (View Menu > Presentation > Hierarchical) to see the clean src/main/java and src/test/java folders nested under a collapsed src entry (or it might not show the root src at all, depending on your view settings).
  • Pro tip: Use the Maven Projects view (Window > Show View > Other... > Maven > Maven Projects) for an even cleaner view of your project’s Maven-specific directories.

Method 3: Use Working Sets to Curate What You See

If you want more control over which folders are displayed, Working Sets are a great option:

  • Click the View Menu in Package Explorer > Working Sets > Edit Working Sets....
  • Click New, choose either Java or Resource as the working set type, give it a name (like "Project Sources"), and click Next.
  • Select only the folders you want to see (src/main/java, src/test/java, maybe src/main/resources) and click Finish.
  • Back in Package Explorer, click View Menu > Top Level Elements > Working Sets. Now only the folders in your Working Set will be visible, and the root src will be hidden entirely.

Quick Note

If you ever need to bring the root src back, just reverse the steps: for Method 1, uncheck the folder in Filters; for Method 3, switch back to Projects as the top-level element.

内容的提问来源于stack exchange,提问作者nappyfalcon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:47:51