Eclipse .classpath/.project 文件中有什么? [英] What's in an Eclipse .classpath/.project file?
问题描述
我们最近遇到了一个团队成员的 Eclipse 项目问题.Tomcat 没有部署应用程序的 JAR.
We recently had an issue with an Eclipse project for one of our team members. Tomcat was not deploying JARs of the application.
我们最终注意到 .classpath
Eclipse 文件与项目正常的团队成员不同.我们将 .classpath
文件替换为一个项目中的文件,该文件正常且 Tomcat 部署已完成.
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.
只是出于好奇并想知道如果出现问题时要查看什么,.classpath
和 .project
文件中的内容.我可以在那里添加什么,这意味着什么?
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?
推荐答案
Eclipse 是插件的运行时环境.实际上,您在 Eclipse 中看到的所有内容都是安装在 Eclipse 上的插件的结果,而不是 Eclipse 本身.
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.
.project
文件由核心 Eclipse 平台维护,其目标是从通用的、独立于插件的 Eclipse 视图描述项目.项目名称是什么?它指的是工作区中的其他哪些项目?用于构建项目的构建器是什么?(请记住,构建"的概念并不专门适用于 Java 项目,也适用于其他类型的项目)
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)
.classpath
文件由 Eclipse 的 JDT 特性(特性 = 插件集)维护.JDT在项目中持有多个这样的元"文件(参见项目内的.settings
目录);.classpath
文件只是其中之一.具体来说,.classpath
文件包含 JDT 特性正确编译项目所需的信息:项目的源文件夹(即要编译的内容);输出文件夹(编译到的位置);和类路径条目(例如工作区中的其他项目、文件系统上的任意 JAR 文件等).
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).
盲目地将此类文件从一台机器复制到另一台机器可能会有风险.例如,如果将任意 JAR 文件放置在类路径上(即,位于工作区外部并通过绝对路径命名引用的 JAR 文件),则 .classpath
文件将呈现为非便携,必须修改才能便携.可以遵循某些最佳实践来保证 .classpath
文件的可移植性.
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.
这篇关于Eclipse .classpath/.project 文件中有什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!