Eclipse .classpath/.project 文件中有什么?
最近,我们的一位团队成员在 Eclipse 项目中遇到了问题。 Tomcat 没有部署应用程序的 JAR。
我们最终注意到 .classpath
Eclipse 文件与项目正常的团队成员的文件不同。我们将 .classpath
文件替换为项目中的文件,该文件正常并且 Tomcat 部署已完成。
只是出于好奇,并想知道如果出现问题,将来要查看什么,.classpath 和 .project
文件中的内容。我可以在那里添加什么,这一切意味着什么?
We recently had an issue with an Eclipse project for one of our team members. Tomcat was not deploying JARs of the application.
We eventually noticed the .classpath
Eclipse file was not the same as for the team members where the project was OK. We replaced the .classpath
file with one from a project that was OK and the Tomcat deploy was complete.
Just out of curiosity and to know at what to look in the future if something is wrong, what is inside the .classpath
and .project
files. What can I add in there, what does it all mean?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Eclipse 是插件的运行时环境。事实上,您在 Eclipse 中看到的所有内容都是 Eclipse 上安装的插件的结果,而不是 Eclipse 本身。
.project
文件由核心 Eclipse 平台维护,其目标是从通用的、独立于插件的 Eclipse 视图描述项目。该项目的名称是什么?它指的是工作区中的哪些其他项目?用于构建项目的构建器是什么? (请记住,“构建”的概念并不专门适用于 Java 项目,也适用于其他类型的项目).classpath
文件由 Eclipse 的 JDT 功能维护(功能 em> = 插件集)。 JDT 在项目中保存多个此类“元”文件(请参阅项目内的.settings
目录);.classpath
文件只是其中之一。具体来说,.classpath
文件包含 JDT 功能正确编译项目所需的信息: 项目的源文件夹(即要编译的内容);输出文件夹(编译到的位置);和类路径条目(例如工作区中的其他项目、文件系统上的任意 JAR 文件等)。盲目地将此类文件从一台计算机复制到另一台计算机可能存在风险。例如,如果将任意 JAR 文件放置在类路径上(即,位于工作区外部并通过绝对路径命名引用的 JAR 文件),则
.classpath
文件将呈现为非是可移植的,并且必须进行修改才能可移植。可以遵循某些最佳实践来保证 .classpath 文件的可移植性。Eclipse is a runtime environment for plugins. Virtually everything you see in Eclipse is the result of plugins installed on Eclipse, rather than Eclipse itself.
The
.project
file is maintained by the core Eclipse platform, and its goal is to describe the project from a generic, plugin-independent Eclipse view. What's the project's name? what other projects in the workspace does it refer to? What are the builders that are used in order to build the project? (remember, the concept of "build" doesn't pertain specifically to Java projects, but also to other types of projects)The
.classpath
file is maintained by Eclipse's JDT feature (feature = set of plugins). JDT holds multiple such "meta" files in the project (see the.settings
directory inside the project); the.classpath
file is just one of them. Specifically, the.classpath
file contains information that the JDT feature needs in order to properly compile the project: the project's source folders (that is, what to compile); the output folders (where to compile to); and classpath entries (such as other projects in the workspace, arbitrary JAR files on the file system, and so forth).Blindly copying such files from one machine to another may be risky. For example, if arbitrary JAR files are placed on the classpath (that is, JAR files that are located outside the workspace and are referred-to by absolute path naming), the
.classpath
file is rendered non-portable and must be modified in order to be portable. There are certain best practices that can be followed to guarantee.classpath
file portability.上述文件不提供完整参考,因为它们可以通过各种插件进行扩展。
基本上,.project 文件存储项目设置,例如构建器和项目性质设置,而 .classpath 文件定义运行期间要使用的类路径。类路径文件包含与项目中的文件夹相对应的 src 和 target 条目; con 条目用于描述某种“虚拟”条目,例如 JVM 库或 eclipse 插件依赖项(正常的 Java 项目依赖项以不同方式显示,使用特殊的 src 条目)。
Complete reference is not available for the mentioned files, as they are extensible by various plug-ins.
Basically, .project files store project-settings, such as builder and project nature settings, while .classpath files define the classpath to use during running. The classpath files contains src and target entries that correspond with folders in the project; the con entries are used to describe some kind of "virtual" entries, such as the JVM libs or in case of eclipse plug-ins dependencies (normal Java project dependencies are displayed differently, using a special src entry).
此 Eclipse 文档包含有关
.project
文件中标记的详细信息:项目描述文件它描述了
.project
文件 作为:This eclipse documentation has details on the markups in
.project
file: The project description fileIt describes the
.project
file as: