Java 如何在eclipse中链接项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6580360/
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
How to link project in eclipse
提问by Ballon
I have a java project and I want to develop it without replacing the source code from its place. I want to link my code to my workspace without replace physically?
我有一个 java 项目,我想在不替换源代码的情况下开发它。我想将我的代码链接到我的工作区而不进行物理替换?
采纳答案by Mike Kwan
- Select the
Project
you want to reference from onPackage Explorer
- Right-click and go to
Properties
( or hit Ctrl-Enter ). - Under
Projects
inJava Build Path
you can add another project which is currently open.
- 从开始选择
Project
您要参考的Package Explorer
- 右键单击并转到
Properties
( 或按 Ctrl-Enter )。 - 根据
Projects
中Java Build Path
可以添加另一个项目,该项目是当前打开。
If you want to override a class you can make a copy of it in your current project and move it further up in the classpath in Order and Export
.
如果你想覆盖一个类,你可以在当前项目中制作它的副本,然后在Order and Export
.
回答by Adeel Ansari
Linking Source
链接源
Project properties -> Java build path (tree-item) -> Source (tab) -> Link source (button)
Project properties -> Java build path (tree-item) -> Source (tab) -> Link source (button)
Linking Projects
链接项目
Project properties -> Java build path (tree-item) -> Projects (tab) -> Add... (button)
Project properties -> Java build path (tree-item) -> Projects (tab) -> Add... (button)
Suggestion
建议
See Eclipse help topic: Workbench User Guide > Tasks > Working with projects, folders and files > Creating linked resources
.
请参阅 Eclipse 帮助主题:Workbench User Guide > Tasks > Working with projects, folders and files > Creating linked resources
.
回答by dan
You can link to a project that exists outside your workspace. This allows the project to continue to exist outside but be referable for purposes of browsing source, debugging, breakpoints, etc. In Eclipse, from the menu:
您可以链接到工作区之外的项目。这允许项目继续存在于外部,但可用于浏览源代码、调试、断点等目的。在 Eclipse 中,从菜单:
- Select
File | Import...
and chooseGeneral > Existing Projects into Workspace
- On the next panel in the dialog, browse to the location of the project and ensure it's selected in the listbox.
- Be sure to not check the checkbox
Copy projects into workspace
. Click Finish.
- 选择
File | Import...
并选择General > Existing Projects into Workspace
- 在对话框的下一个面板上,浏览到项目的位置并确保它在列表框中被选中。
- 一定不要选中复选框
Copy projects into workspace
。单击完成。
Changes you make in the project in this workspace will be reflected into the project in it's native location.
您在此工作区中的项目中所做的更改将反映到项目的本机位置中。
Be sure that when you remove the project reference from the non-natively owned workspace, that you don't Delete project contents on disk (cannot be undone)
.
请确保当您从非本地拥有的工作区中删除项目引用时,您不会Delete project contents on disk (cannot be undone)
.
回答by Atul Kumbhar
For Maven based projects, following worked for me:
对于基于 Maven 的项目,以下对我有用:
Make sure to have following checkbox checked
确保选中以下复选框
Project properties -> Java build path (tree-item) -> Libraries (tab) -> Maven Dependencies (tree-item) -> Edit (button) -> Maven Project Settings (link) -> Resolve dependencies from Workspace projects (checkbox)
项目属性-> Java 构建路径(树项)-> 库(选项卡)-> Maven 依赖项(树项)-> 编辑(按钮)-> Maven 项目设置(链接)-> 从工作区项目中解决依赖项(复选框)