如何在 Eclipse 中引用不同的 Java 项目 [英] How to reference a different Java project in Eclipse

查看:27
本文介绍了如何在 Eclipse 中引用不同的 Java 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 Project1 和 Project2.项目 1 依赖于项目 2.我有点累了,每次在 Project2 中进行一些代码更改时,我都必须导出 Project2 JAR 文件,并将其复制到 Project1 的 lib 文件夹中.

I have Project1 and Project2. Project1 is dependent of Project2. I am sort of tired that every time I make some code changes in Project2, I have to Export Project2 JAR file, and copy it into lib folder of Project1.

有没有办法自动实现?或者,有没有其他方法可以让 Project1 知道 Project2 发生了一些变化?

在项目的Build Path中,有一种方法可以指定对Workspace中其他项目的引用,但这似乎没有任何作用?它实际上有什么作用?

In Build Path of the project, there is a way to specify references to other projects in Workspace, but this doesn't seem to do anything? What does it actually do?

我在某处读到我可以使用部署属性来自动化这个过程,但我找不到它.

I was reading somewhere that I can use Deployment Properties to automatize this process, but I can't find it.

更新:呃,我是 C# 开发者,有一些 Java 开发经验(主要是 Android 开发),我可能会问一些愚蠢的问题,所以请耐心等待...

UPDATE: Uh, I am C# developer and have some experience in Java development (mostly Android development), I might ask stupid questions, so please bear with me...

Project1 是标准的 Java 项目(在客户端机器上运行,使用 Swing 等.).Project2 是动态 Web 项目(原因不明).它所做的唯一一件事就是调用 webservice(我不需要担心的第三个项目)并将结果传递回 Project1.Project2 包含那些 Axis2 webserviceStub.java 文件...每个人都知道,然后,我必须重新创建这些存根文件,然后我必须导出 JAR 文件并将其移动到 Project1.Project2,虽然是Web Project,但其实是运行在客户端的代码.

Project1 is standard Java Project (Run on client's machine, uses swing, etc..). Project2 is Dynamic Web Project (for to me unknown reason). The only thing it does is calling webservice (third project I don't need to worry about) and passing result back to Project1. Project2 contains those Axis2 webserviceStub.java files... Every know and then, I have to recreate these stub files then I have to export JAR file and move it to Project1. Project2, even though it is Web Project, it is actually code that runs on client.

在构建路径中只是简单的项目引用对我不起作用.

Just simple project referencing in Build Path doesn't work for me.

谢谢

推荐答案

右键单击Project1,然后单击属性.在出现的对话框中,选择 Java 构建路径,然后单击 项目 选项卡.在那里,将 Project2 添加到构建路径.

Right click on Project1, then click on Properties. In the dialog that comes up, select Java Build Path, and then click on the Projects tab. There, add Project2 to the build path.

如果Project1是一个网络应用程序,您需要确保您的部署程序集(相同的属性 UI)具有Project2 还有.

If Project1 is a web app, you need to make sure your Deployment Assembly (same Properties UI) has Project2 there as well.

这篇关于如何在 Eclipse 中引用不同的 Java 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆