简体   繁体   中英

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. I want to link my code to my workspace without replace physically?

  1. Select the Project you want to reference from on Package Explorer
  2. Right-click and go to Properties ( or hit Ctrl-Enter ).
  3. Under Projects in Java Build Path you can add another project which is currently open.

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 .

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 .

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:

  1. Select File | Import... File | Import... and choose 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 . 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) .

For Maven based projects, following worked for me:

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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