构建路径中所需的项目 [Eclipse]

发布于 2024-09-09 00:18:22 字数 339 浏览 0 评论 0原文

我的构建路径有问题。在我的 Web 项目中,所有 .jar 都必须放在项目中,因此我无法使用 WEB-INF/lib 资源在其中添加 .jar。

所以我创建了一个 Lib 项目,这样我就可以像使用 WEB-INF/lib 一样使用它。问题是我无法使其正常工作。 看起来相当简单,我创建一个 Java 项目,将所有 .jar 放入其中,然后告诉构建路径在我放置此 .jar 的特定位置查看该项目。

我尝试过创建其他类型的项目(非 java 项目、实用程序 Java EE 项目...)并更改依赖项目的本机库位置。一切都是徒劳。

那么,如何让一个项目看到另一个项目的 .jar 呢?

感谢您的任何帮助。

I have a problem with my build path. In my web project all .jar must go on projects, so I cannot use the WEB-INF/lib resource to add .jars there.

So I created a Lib project so I could use it in the same way I use the WEB-INF/lib. Problem is I am not beeing able to make it work properly.
Seems fairly easy, I create a Java project, put all .jar in it and then tell the build path to look at that project in the specific place I put this .jars.

I have tried creating other types of project (a non-java project an utility Java EE project...) and changing the native libreary location of the depended project. All futile.

So, How can I make one project see the .jar of another project?

Thanks for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

仙女 2024-09-16 00:18:22

我不确定,但我认为你要做的就是项目>属性>构建路径>排序并导出并标记你想要通过的所有库。

I'm not sure, but I think what you have to do is got to project>properties>build path>order and export and mark all the libs you want to pass through.

冷清清 2024-09-16 00:18:22

在您的项目属性中的“J2EE 模块依赖项”/“Web 库” 下添加您的外部 jar

In your project properties under "J2EE Module Dependencies"/"Web Libraries" add your external jars there

淡忘如思 2024-09-16 00:18:22

使用 Maven 将是一个更好的选择,因为它实际上是 jar 文件的存储库。另一种选择是简单地拥有一个共享 lib 目录,然后配置类路径以包含该位置的 jar 文件,最好使用类路径变量来定义其位置。

将它们放入 Eclipse 项目中确实没有多大意义,它没有增加任何价值。您遇到的另一个问题是,在运行时的战争中将需要这些 jar,因此如果不将它们放入 lib 目录中,它们将必须出现在类加载器可以找到它们的其他位置,例如服务器类路径或某些其他共享位置(这将取决于供应商)。

Using Maven would be a better alternative since it is actually a repo for jar files. Another alternative is to simply have a shared lib directory, then you configure your classpath to include the jar files at that location, preferably using a classpath variable to define its location.

There really isn't much point to putting them in an eclipse project, it adds no value. The other problem you have is that the jars are going to be required in the war at runtime, so without putting them in the lib directory, they will have to appear somewhere else that the classloader can find them, such as the servers classpath or some other shared location (this will be vendor dependent).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文