将 Java 源代码导入 Eclipse 以避免混淆引用的正确方法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/764256/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 19:12:12  来源:igfitidea点击:

What's the right way to import Java source into Eclipse to avoid messing up references?

javaeclipseimport

提问by William

I created a java project and then tried to import Java source code from two different projects. I've been working on it for a few hours, deleting and re-creating the project dozens of times to try to reconcile all of the messed up references between these two projects - which other people say are supposed to work together reliably.

我创建了一个 java 项目,然后尝试从两个不同的项目中导入 Java 源代码。我一直在研究它几个小时,删除并重新创建项目数十次,以尝试协调这两个项目之间所有混乱的引用 - 其他人说它们应该可靠地协同工作。

What I'm doing is using svn to download the source from each project. And then using File-Import-File System in Eclipse. Once it's in Eclipse, I'm using the Refactor-Move command to move everything into the same src folder. That's where I get all the red marks indicating messed up references.

我正在做的是使用 svn 从每个项目下载源代码。然后在 Eclipse 中使用 File-Import-File System。一旦它在 Eclipse 中,我就使用 Refactor-Move 命令将所有内容移动到同一个 src 文件夹中。这就是我得到所有指示混乱引用的红色标记的地方。

What's the right way to import Java source into Eclipse to avoid messing up references?

将 Java 源代码导入 Eclipse 以避免混淆引用的正确方法是什么?

Surely not everyone goes about it the way I am doing it - or else no one would get anything done in Eclipse. My assumption here is that I am completely clueless about Eclipse and just don't know the easy way to reconcile these two batches of compatible code.

肯定不是每个人都像我那样去做——否则没有人会在 Eclipse 中完成任何事情。我的假设是我对 Eclipse 完全一无所知,只是不知道协调这两批兼容代码的简单方法。

采纳答案by John Ellinwood

Why do they have to be the same project? You could import then into two projects and have one depend on the other. Or have them both depend on a third project. If you still want one project, you can create a new source folder for each one instead of trying to move then into a single source folder. An eclipse project can have multiple source folders. Ideally, once you got it working, you'd also want to check in the eclipse project (.project file, .settings, etc) into svn also so others can check them out directly into eclipse instead of having to import into a new project every time. It would make versioning easier.

为什么它们必须是同一个项目?您可以将然后导入到两个项目中,并使一个依赖于另一个。或者让它们都依赖于第三个项目。如果您仍然想要一个项目,您可以为每个项目创建一个新的源文件夹,而不是尝试将其移动到单个源文件夹中。一个 eclipse 项目可以有多个源文件夹。理想情况下,一旦您开始工作,您还需要将 eclipse 项目(.project 文件、.settings 等)检入 svn,以便其他人也可以将它们直接检出到 eclipse 中,而不必导入到新项目中每次。这将使版本控制更容易。

回答by Nimo

  1. Add the source to the project directory
  2. Right-click on project > refresh
  1. 将源添加到项目目录
  2. 右键单击项目>刷新

Voila! it's there :)

瞧!在那 :)