Eclipse创建类时未列出的包。

huangapple go评论79阅读模式
英文:

Packages not listed while creating a class in Eclipse

问题

我在Eclipse中遇到了一些问题,我觉得它们之间是相关的。

  1. 我无法以样式package.subpackage1.subpackage2的形式看到包的结构,但在Windows资源管理器中我们可以看到文件夹结构,即

    package

    |--- subpackage1

    |--- subpackage2

  2. 当我尝试在包中创建一个类时,它被添加到默认包中,我无法看到包,因为包没有列出。

问题的示例

我也检查了透视图 - 无论是Java透视图还是JavaEE透视图,问题仍然存在。我还将“Package Presentation”更改为“Hierarchical”,但没有帮助。我在Package Explorer和Project Explorer中都进行了检查。我正在使用Photon Release(4.8.0)。

我尝试在Google和StackOverflow上搜索了这个问题,但没有找到相关的内容,因此寻求社区的帮助。

英文:

I am facing a couple of issues in Eclipse and I feel they are related.

  1. I cannot see the structure of packages in style package.subpackage1.subpackage2 but in the folder structure we see in windows explorer i.e.
    <br> package
    <br> |--- subpackage1
    <br> |---subpackage2

  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. 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).

I tried searching it on Google and here in StackOverflow too but found nothing relevant thus seeking help from the community.

答案1

得分: 0

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

英文:

You put your Java class files into the source folder <code>src/main/<b>resources</b></code> (where in Maven by default .java files will be ignored to be compiled) instead of into the source folder <code>src/main/<b>java</b></code>.

答案2

得分: 0

问题似乎是您没有源文件夹。
右键单击您的项目->生成路径->配置生成路径

在配置生成路径中选择“源”选项卡。添加源文件夹src/main/java。
在此文件夹中创建您的包和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.
Create your packages and java files in this folder

huangapple
  • 本文由 发表于 2020年9月18日 14:54:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/63950696.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定