简体   繁体   English

如何在 eclipse 中链接项目

[英]How to link project in eclipse

I have a java project and I want to develop it without replacing the source code from its place.我有一个 java 项目,我想在不替换源代码的情况下开发它。 I want to link my code to my workspace without replace physically?我想将我的代码链接到我的工作区而不进行物理替换?

  1. Select the Project you want to reference from on Package Explorer Select 您要在Package Explorer上引用的Project
  2. Right-click and go to Properties ( or hit Ctrl-Enter ).右键单击 go 到Properties (或按 Ctrl-Enter )。
  3. Under Projects in Java Build Path you can add another project which is currently open.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 .如果您想覆盖 class ,您可以在当前项目中复制它,然后在Order and Export的类路径中将其进一步向上移动。

Linking Source链接源

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)

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

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 中,从菜单:

  1. Select File | Import... Select File | Import... File | Import... and choose General > Existing Projects into Workspace File | Import...并选择General > Existing Projects into Workspace
  2. On the next panel in the dialog, browse to the location of the project and ensure it's selected in the listbox.在对话框的下一个面板上,浏览到项目的位置并确保它在列表框中被选中。
  3. Be sure to not check the checkbox Copy projects into workspace .一定不要选中复选框Copy projects into workspace Click Finish.单击完成。

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)

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) 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 )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM