简体   繁体   English

Eclipse将java项目的src文件夹视图显示为所有包和子包

[英]Eclipse showing java project src folder view as all packages and subpackages

Not sure how to really ask this question since I don't know what everything is called but I'll try to do the best I can. 不知道如何真正问这个问题,因为我不知道所谓的一切,但我会尽力做到最好。

So as I was cleaning up my classes. 所以我正在清理课程。 I right clicked my project and selected refresh. 我右键单击了我的项目并选择了刷新。 Then all of a sudden my project view changed, the src folder shows everything as packages and '.' 然后突然我的项目视图发生了变化,src文件夹显示了所有内容作为包和'。' separated subpackages. 分开的子包。 And all my code package declarations seems now to be undiscoverable. 而我所有的代码包声明似乎都是不可发现的。

I've attached a photo, hopefully you can petter understand this...How can I fix this to have the correct directory view/structure. 我附上了一张照片,希望你能够理解这一点......我怎样才能解决这个问题,以获得正确的目录视图/结构。

Edit: 编辑:

Here is what I have linked to my JAVA build path 这是我链接到我的JAVA构建路径

I don't understand what is happening? 我不明白发生了什么? How can all of a sudden my project screw up like it has? 我的项目怎么能像它一样搞砸了? Any help will be much appreciated 任何帮助都感激不尽

Look at the 'Java Build Path' in the project 'Properties' and check that you have the correct 'Source' folders. 查看项目“属性”中的“Java构建路径”,并检查您是否具有正确的“源”文件夹。 It looks like you may have just 'src' as a source folder when you should have 'src/main/java', 'src/test/java'... 当你应该有'src / main / java','src / test / java'时,看起来你可能只有'src'作为源文件夹...

我能够通过maven>更新项目修复此问题,然后刷新...

In addition to the previous answer you also may use empty package filter: At the top-right of the Package Explorer view, there's a downward-pointing triangle. 除了上一个答案,您还可以使用空包过滤器:在Package Explorer视图的右上角,有一个向下指向的三角形。 If you hover your mouse pointer over it you'll see View Menu . 如果将鼠标指针悬停在它上面,您将看到“ 查看菜单”

Click the View Menu , select Filters , put a check next to Empty Packages , then click OK . 单击“ 查看”菜单 ,选择“ 过滤器” ,选中“ 空包”旁边的复选框,然后单击“ 确定” Same way you could tune other options for Package explorer such as file types to show etc. 同样,您可以调整Package explorer的其他选项,例如要显示的文件类型等。

The following worked for me: 以下对我有用:
Right Click on src (which is shown like empty package in my project) -> Build Path -> Use As Source Folder 右键单击src (在我的项目中显示为空包) - > Build Path - > Use As Source Folder

Well, it seems pretty clear that your hierarchy does not match the name of your package, so just fix your hierarchy. 好吧,很明显您的层次结构与包的名称不匹配,因此只需修复您的层次结构。 It will be easier if you switch to the hierarchical view of the packages. 如果切换到包的分层视图会更容易。 To do so, go to Package explorer , View menu (arrow icon pointing to the bottom), Package presentation , Hierarchical . 为此,请转到Package explorerView菜单 (指向底部的箭头图标), Package presentationHierarchical

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM