导入到eclipse的项目不会显示源包

时间:2012-08-08 19:02:38

标签: java eclipse

为什么将导入到eclipse的项目导致不显示包,而只显示常规文件夹结构?

我的.project文件

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>hello-connector</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.m2e.core.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.m2e.core.maven2Nature</nature>
    </natures>
</projectDescription>

4 个答案:

答案 0 :(得分:3)

我假设你没有导入Eclipse项目,而是IDE独立的东西。

您需要编辑项目设置。在java构建的路径设置中,在第一个选项卡上,您必须将源文件夹添加为 - well - 源文件夹。 ; - )

答案 1 :(得分:1)

从导航器视图中检查项目根目录的内容。您应该看到.classpath文件。如果缺少该文件,则导入无法正常工作(请注意,版本控制系统甚至某些文件系统浏览器有时会忽略两个关键项目配置文件.project和.classpath)。如果.classpath存在,则必须手动重新配置.classpath(或检查您是否正在使用包浏览器视图)。

尝试将.project更改为:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>hello-connector</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.m2e.core.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.m2e.core.maven2Nature</nature>
        <nature>org.eclipse.jdt.core.javaNature</nature>
    </natures>
</projectDescription>

答案 2 :(得分:0)

从.project文件我假设这是一个Maven项目。尝试右键单击项目根目录,然后选择配置 - &gt;转换为Maven项目。之后,您可能需要再次右键单击该项目并选择Maven - &gt;更新项目配置。希望它有所帮助。

答案 3 :(得分:0)

我通过以下方式获得要显示的包

mvn eclipse:eclipse

按照警告说明

安装激活罐
[WARNING] An error occurred during dependency resolution.
    Failed to retrieve javax.activation:activation-1.1-osgi
Caused by: Could not find artifact javax.activation:activation:jar:1.1-osgi in mulesoft-releases (http://repository.mulesoft.org/releases/)

Try downloading the file manually from:
    https://maven-repository.dev.java.net/nonav/repository/javax.activation/jars/activation-1.1.jar

Then, install it using the command:
    mvn install:install-file -DgroupId=javax.activation -DartifactId=activation -Dversion=1.1-osgi -Dpackaging=jar -Dfile=/path/to/file

哦我也清楚POM文件的依赖关系到这个

<repositories>
    <repository>
        <id>mulesoft-releases</id>
        <name>MuleSoft Releases Repository</name>
        <url>http://repository.mulesoft.org/releases/</url>
        <layout>default</layout>
    </repository>
</repositories>

所以在所有这些之后我不确定是什么帮助..我确实有其他错误,但至少我可以继续前进。 谢谢!