如何使用 TFS (Team Explorer Everywhere) 插件纠正与 Eclipse 上的代码完成相关的错误?

发布于 2024-12-11 09:42:51 字数 844 浏览 0 评论 0原文

我正在使用 Eclipse(实际上是 IBM 的 AST for WebSphere - 基于 Eclipse 3.2.1)和 TFS 的 Team Explorer Everywhere 插件。启动新项目并从 TFS 获取代码后,我注意到尝试更新任何 Java 代码都会导致以下错误消息:

 "This compilation unit is not on the build path of a Java project."

搜索网络导致建议将以下内容添加到项目的 .project 文件中:

<natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
</natures>

但是,这样做会导致我的包声明(在任何类中)被标记为如下:

The declared package "some.package.name" does not match the expected package "".
The type java.lang.Object cannot be resolved. It is indirectly referenced from the required .class files.

另一个建议是更改应用程序的构建路径,例如通过删除并重新建立 JRE 系统库。我的经验表明,只有将“natures”添加到 .project 文件中时,此选项才在“属性”菜单中可用。

作为最后的手段,我尝试生成一个新的工作区,并得到了相同的结果。

我是否需要添加 TFS 的特定“性质”,或者该问题的其他解决方案?

I am using Eclipse (actually, IBM's AST for WebSphere - based on Eclipse 3.2.1) and the Team Explorer Everywhere plugin for TFS. After starting a new project and getting the code from TFS, I've noticed that attempting to update any Java code results in the following error message:

 "This compilation unit is not on the build path of a Java project."

Searching the web resulted in a suggestion that the following be added to the .project file of the project:

<natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
</natures>

However, doing this results in my package declarations (within any classes) to be marked as follows:

The declared package "some.package.name" does not match the expected package "".
The type java.lang.Object cannot be resolved. It is indirectly referenced from the required .class files.

Another suggestion is to change the build path of the application, such as by deleting and reestablishing the JRE system library. My experience has shown that this option is only available in the Properties menu if the "natures" are added to the .project file.

As a last resort I tried generating a new workspace and had the same results there.

Is there a specific "nature" for TFS that I need to add, or another solution to this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

带上头具痛哭 2024-12-18 09:42:51

您实际上要进口什么?它是现有的 Java 项目吗?这是一个 Eclipse 项目吗?您要导入的文件夹是否包含 .project 文件,还是位于子目录中?或者根本没有 .project 文件?

关于包声明不正确的错误听起来像是您可能在项目层次结构中导入了更深层次的内容(即导入 $/Project/src/some/package/name 而不是 `$/Project' .) 这可能吗?

What are you actually importing? Is it an existing Java project? Is it an Eclipse project? Does the folder you're importing contain the .project file, or is it in a subdirectory? Or is there no .project file at all?

The error about package declarations being incorrect makes it sounds like you might have imported something deeper in the project hierarchy (ie, importing $/Project/src/some/package/name instead of `$/Project'.) Is this possible?

末骤雨初歇 2024-12-18 09:42:51

我找到了这个问题的答案 - 它与我从 TFS 导入应用程序的方式有关。

我们的应用程序结构设置为(例如):

app-name-app
|
应用程序名称-ear
应用名称之战
app-name-jar

所以,只需根据需要导入ear、war、jar等即可。导入 app-name-app 是问题的根源。对于我的项目,我有一个耳朵和一场战争 - 仅导入这两个项目就可以使 AST/Eclipse 正常运行。

I've found the answer to this problem - it is related to how I was importing the application from TFS.

Our application structure is setup as (for example):

app-name-app
|
app-name-ear
app-name-war
app-name-jar

So, just import the ear, war, jar, etc. as needed. Importing app-name-app was the source of the problem. For my project, I have an ear and a war - importing just these two items resulted in AST/Eclipse behaving correctly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文