Eclipse:如何添加现有的源文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2838229/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse: How to add an existing source folder?
提问by evilfred
I have a directory called c:\RemoteSrc . Under this there are 3 directories which are currently source folders (I think? the icon is an open folder with a little orange grid in it) in my Eclipse project. I have dropped a new directory under c:\RemoteSrc which I also want to add to my project.
我有一个名为 c:\RemoteSrc 的目录。在此之下,我的 Eclipse 项目中有 3 个目录,它们当前是源文件夹(我认为?图标是一个打开的文件夹,里面有一个橙色的小网格)。我在 c:\RemoteSrc 下放置了一个新目录,我也想将其添加到我的项目中。
BUT
但
If I right click on my project and go "Build Path..." -> "Link Source" and try to add it it tells me "Folder already exists with a different case". Yes i KNOW that the folder already exists THATS WHY IM TRYING TO ADD IT.
如果我右键单击我的项目并转到“构建路径...”->“链接源”并尝试添加它,它会告诉我“文件夹已经存在,但具有不同的情况”。是的,我知道该文件夹已经存在,这就是我尝试添加它的原因。
采纳答案by Greg Adamski
I think all you need to do is refresh the project. Eclipse does not automatically pick up folders (or files) dropped into it's project directory.
我认为您需要做的就是刷新项目。Eclipse 不会自动选取放入其项目目录中的文件夹(或文件)。
回答by nevets1219
For Linked Sources, you should have something like the following in your .classpath
对于链接源,您应该在您的 .classpath
<classpathentry kind="src" path="module_name"/>
With a corresponding matching entry (within <linkedResources>
)in your .project
使用相应的匹配条目(在 内<linkedResources>
).project
<link>
<name>module_name</name>
<type>2</type>
<location>path/to/your/module</location>
</link>
NOTE: Removing a linked project doesn't necessarily remove it from the project.
注意:删除链接的项目并不一定将其从项目中删除。
回答by VonC
A screen capture might help, but if the GUI is un-cooperative, you can:
屏幕截图可能会有所帮助,但如果 GUI 不配合,您可以:
- close Eclipse
- open the
.classpath
file which defines your project (it may be located in your workspace) - see if you can define a new
classpathentry
of kind "src
": this is not the easymethod, but that may give you an idea why the GUI refuses to define the same entry.
- 关闭日食
- 打开
.classpath
定义您的项目的文件(它可能位于您的工作区中) - 看看你是否可以定义一个新
classpathentry
的“src
”:这不是一个简单的方法,但这可能会让你知道为什么 GUI 拒绝定义相同的条目。
回答by Michael Shlayen
No need to close Eclipse. Open .project file using Notepad++, find link to the existing source/folder and delete it. Save the file. Refresh the project in Eclipse. Now you should be able to link it again.
无需关闭 Eclipse。使用 Notepad++ 打开 .project 文件,找到指向现有源/文件夹的链接并将其删除。保存文件。在 Eclipse 中刷新项目。现在您应该能够再次链接它。
回答by sjr_ee
I had a problem where I had created a /src directory in my working directory and then wanted to link another directory with additional files to import. The "existing directory" turned out to be because the directory I was trying to link was also called "/src", even though the path was different. I guess Eclipse can't have two /src directories in the same project, similar to trying to mount two file systems at the same node. I rearranged the directories so there was only one /src, and all was well.
我有一个问题,我在我的工作目录中创建了一个 /src 目录,然后想将另一个目录与要导入的其他文件链接起来。“现有目录”原来是因为我试图链接的目录也被称为“/src”,即使路径不同。我猜 Eclipse 不能在同一个项目中有两个 /src 目录,类似于尝试在同一个节点上挂载两个文件系统。我重新排列了目录,所以只有一个 /src,一切都很好。
回答by Darshan Kumar
There were conflicts when I tried to update my project which resulted in creation of multiple .classpath files.. SO removing the copies and reverting the latest .classpath file and then refreshing/rebuilding project ,solved the issue for me.
当我尝试更新我的项目时发生了冲突,导致创建了多个 .classpath 文件。所以删除副本并恢复最新的 .classpath 文件,然后刷新/重建项目,为我解决了这个问题。
Hope it helps!
希望能帮助到你!