简体   繁体   English

在 Eclipse 中创建类时未列出的包

[英]Packages not listed while creating a class in Eclipse

I am facing a couple of issues in Eclipse and I feel they are related.我在 Eclipse 中面临几个问题,我觉得它们是相关的。

  1. I cannot see the structure of packages in style package.subpackage1.subpackage2 but in the folder structure we see in windows explorer ie我在样式 package.subpackage1.subpackage2 中看不到包的结构,但在我们在 Windows 资源管理器中看到的文件夹结构中,即
    package包裹
    |--- subpackage1 |--- 子包1
    |---subpackage2 |---子包2

  2. While I try to create a class in a package , it is added to a default package and I cannot see a package as the packages are not listed.当我尝试在包中创建一个类时,它被添加到默认包中,我看不到包,因为这些包没有列出。

An illustration of the problem问题说明

I checked perspectives as well - the issue persists in Java or JavaEE perspectives.我也检查了透视图 - 该问题在 Java 或 JavaEE 透视图中仍然存在。 I also changed the "Package Presentation" to "Hierarchical" but it wouldn't help.我还将“包演示文稿”更改为“分层”,但无济于事。 I checked with Package Explorer as well as Project Explorer.我检查了包资源管理器以及项目资源管理器。 I am using Photon Release (4.8.0).我正在使用 Photon Release (4.8.0)。

I tried searching it on Google and here in StackOverflow too but found nothing relevant thus seeking help from the community.我尝试在 Google 和 StackOverflow 上搜索它,但没有找到相关内容,因此向社区寻求帮助。

您将 Java 类文件放入源文件夹src/main/ resources (在 Maven 中默认情况下.java文件将被忽略以进行编译)而不是放入源文件夹src/main/ java

Problems seem to be that you do not have a source folder.问题似乎是您没有源文件夹。 Right-click on your project -> Build Path -> Configure Build Path右键单击您的项目 -> 构建路径 -> 配置构建路径

In Configure Build Path select Source tab.在配置构建路径中选择源选项卡。 Add source folder src/main/java.添加源文件夹 src/main/java。 Create your packages and java files in this folder在此文件夹中创建您的包和 java 文件

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

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