如何确保实用项目库依赖项打包到 Eclipse Galileo 的最终 EAR 中?

发布于 2024-08-30 07:13:57 字数 1433 浏览 11 评论 0原文

我有一个“实用程序项目”和一个包含该“实用程序项目”的“EAR 项目”。 “实用程序项目”中的所有类最终都会打包为 JAR 并放置在导出的 EAR 的“lib”目录中,例如:

  EAR.ear
    META-INF
      MANIFEST.MF
    lib
      utility.jar (which expands to):
        META-INF
          MANIFEST.MF
        com
          acme
            Foo.class
            Bar.class

但是,“实用程序项目”依赖于一个库 (freemarker.jar),该库具有使用“属性>”添加到构建路径中Java 构建路径 >图书馆。我想做的就是将 freemarker.jar 添加到 EAR,如下所示:

  EAR.ear
    META-INF
      MANIFEST.MF
    lib
      **freemarker.jar**
      utility.jar (which expands to):
        META-INF
          MANIFEST.MF
        com
          acme
            Foo.class
            Bar.class

通过在 Eclipse 中搜索,我发现了 4 种实现此目的的潜在途径,但没有一种有效。如果有人能切入正题并告诉我我实际上应该做什么,那就太好了。但为了以防万一,我将在这里迭代它们:

从“实用程序项目”属性:

  1. 如果我单击“Java 构建路径”> Order and Export”并选择“freemarker.jar”进行导出,该 jar 根本不会出现在 EAR 文件中。
  2. 如果我单击“Java EE 模块依赖项”并选择“freemarker.jar”库作为依赖项,它会显示:

这个 JAR 是一个捆绑库 EAR 项目,应该是 打包在 EAR 的库目录中。 它与清单类冲突 你正在尝试的路径依赖 创造。如果您创建此依赖项, JAR 将打包在根目录中 EAR 的(不是库)目录。 您确定要继续吗?

从“EAR 项目”属性:

  1. 如果我单击“Java EE 模块依赖项 >”添加 JARs...”并导航到“freemarker.jar”,并将其设为依赖项,它将添加到 EAR 的根目录中: /freemarker.jar
  2. 如果我执行与上面相同的操作,但选中“在 Lib Dir”复选框,它将添加到 lib 文件夹中,但包含在另一个 lib 文件夹中: /lib/lib/freemarker.jar

谢谢。

I have a 'Utilty Project', and an 'EAR Project' that includes that 'Utility Project'. All the classes from the 'Utility Project' end up being packaged as a JAR and placed within the 'lib' directory of the exported EAR, for example:

  EAR.ear
    META-INF
      MANIFEST.MF
    lib
      utility.jar (which expands to):
        META-INF
          MANIFEST.MF
        com
          acme
            Foo.class
            Bar.class

However, the 'Utility Project' relies on a library (freemarker.jar) that has been added to the build path using 'Properties > Java Build Path > Libraries'. All I want to do is to get freemarker.jar added to the EAR as follows:

  EAR.ear
    META-INF
      MANIFEST.MF
    lib
      **freemarker.jar**
      utility.jar (which expands to):
        META-INF
          MANIFEST.MF
        com
          acme
            Foo.class
            Bar.class

By searching around within Eclipse I've found 4 potential avenues for achieving this, none of which have worked. If someone can just cut to the chase and tell me what I should actually do, that would be great. But just in case, I'll iterate them here:

From the 'Utility Project' Properties:

  1. If I click 'Java Build Path > Order and Export' and select 'freemarker.jar' for export, the jar does not end up in the EAR file at all.
  2. If I click 'Java EE Module Dependencies' and select the 'freemarker.jar' library as a dependency, it says:

This JAR is a bundled library of an
EAR project and is supposed to be
packed in the EAR's library directory.
It conflicts with the manifest class
path dependency you are trying to
create. If you create this dependency,
the JAR will be packed in the root
(not library) directory of the EAR.
Are you sure you want to proceed?

From the 'EAR Project' Properties:

  1. If I click 'Java EE Module Dependencies > Add JARs...' and navigate to the 'freemarker.jar', and make it a dependency, it gets added to the root of the EAR:
    /freemarker.jar
  2. If I do the same as above, but check the 'In Lib Dir' checkbox, it gets added into the lib folder, but contained within another lib folder:
    /lib/lib/freemarker.jar

Thanks.

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

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

发布评论

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

评论(2

-黛色若梦 2024-09-06 07:13:57

我已经成功解决了这个问题。在“问题”窗口中,我收到以下警告:

类路径条目 /utility-project/lib/freemarker.jar 将不会被导出或发布。
可能会导致运行时 ClassNotFoundExceptions。

我一时兴起尝试使用 Ctrl-1 组合键来获取源代码的快速修复解决方案。事实证明,这还为给定的错误和警告提供了快速修复解决方案。我选择了两个选项中的第一个:

将关联的原始类路径条目标记为发布/导出依赖项。

我的问题消失了!

奇怪的是,这一切似乎都是为了在“Java EE 模块依赖项”属性对话框中选择“freemarker.jar”库,而我自己就是这样做的。这可能是 Eclispe 的错误!

I've managed to solve this problem. In the Problems window I was getting the following warning:

Classpath entry /utility-project/lib/freemarker.jar will not be exported or published.
Runtime ClassNotFoundExceptions may result.

What I tried, at a whim, was to use the Ctrl-1 key combination I've been using to get quick fix solutions for my source code. It turns out this also provides quick-fix solutions for for the given errors and warnings. I chose the first of the two options:

Mark the associated raw classpath entry as a publish/export dependency.

and my problem disappeared!

Bizarrely, all this seems to have done is to cause the 'freemarker.jar' lib to be selected in the 'Java EE Module Dependencies' properties dialog, which I was doing myself anyway. This may be an Eclispe bug!

抚你发端 2024-09-06 07:13:57

@MonoThreaded:使用快速修复后>如果右键单击项目 > 将关联的原始类路径条目标记为已发布/导出依赖项属性> depolyment 程序集你会注意到 eclipse 添加了一个新条目,例如源:/freemaker.jar,部署路径:../lib。您也可以通过选择“添加”>“添加”来执行此操作。 Java 构建路径条目。

@MonoThreaded: After using the quick fix > Mark the associated raw classpath entry as published/export dependency, if you right-click on the project > properties > depolyment assembly you will notice that eclipse has added a new entry, something like source: /freemaker.jar, deploy path: ../lib. You can do that too, by selecting Add > Java Build Path Entry.

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