maven-camel构建问题

发布于 2024-07-10 06:22:23 字数 774 浏览 4 评论 0原文

我有一个简单的应用程序,使用 netbeans 进行开发,使用 Maven 进行构建等。 我的应用程序使用camel,配置了spring XML。 我想构建一个具有依赖项的可执行 jar,因此我使用带有“jar-with-deps”描述符的 Maven-Assembly 插件。 jar 构建正常,但我认为由于所有依赖项都已解开,并且其中一些依赖项与其他依赖项在相同路径中具有相同的资源,因此它们会相互覆盖。 我通过使用 winrar 浏览 jar 来验证这一点,并且发现同一文件在很多地方多次出现。 我认为这是无法通过一些简单的 Maven 配置来解决的,因为我无法停止想要特定路径中的资源的依赖项,该资源也被另一个依赖项使用。 顺便说一句,该应用程序在 netbeans 内运行正常。 我还看到我的应用程序类多次出现。 这更奇怪,但我不明白为什么。

总而言之,我想知道是否:

  1. 是否有任何简单的解决方案可以找到此类冲突,并且如果不纠正它们,至少报告它们? (以及如何)

  2. 我可以告诉归档器(在 Maven 中)不要解开 deps,而只是将 jar 包含在父 jar 中,然后将 jar 包含在清单类路径中,如何? 这会解决问题还是有相同的结果?

  3. 为什么我的应用程序类在同一路径中也多次出现?

    为什么

为了让您了解问题的情况,当使用 WinRAR 查看时,当前生成的 jar 在根路径中有 3 个“log4j.properties”实例,在 meta-inf/ 路径中有 7 个文件“spring.schemas”实例。一些。

I have a simple application using netbeans for developing and maven for building et all. My application uses camel , spring XML configured. I wanted to build an executable jar with dependencies so i am using the maven-assembly plugin with 'jar-with-deps' descriptor.
The jar is built ok but I think that since all the dependencies get unwrapped and some of these have the same resources in the same paths as others, then they overwrite each other. I verified this by browsing the jar with winrar and i found multiple occurences of the same file in many places. I am thinking this is unsolvable by some simple maven configuration because i cannot stop a dependency wanting a resource in a specific path, used also by another dependency. BTW the app runs ok inside netbeans. Also I saw multiple occurences of my application classes. That is more strange, but i cant figure out why.

All in all, I want to know if:

  1. Is there any simple solution that finds such conflicts and at least reports them if not corrects them? (and how)

  2. Can i tell the archiver (in maven) not to unwrap the deps but just include the jars in a parent jar and then just include the jars in the manifest classpath and how? Will this solve the problem or it has the same result?

  3. Why are there also multiple occurrences of my application classes in the same path?

To give you a picture of the problem , the current resulting jar, when viewd with WinRAR, has 3 instances of 'log4j.properties' in root path and 7 instances of file 'spring.schemas' in meta-inf/ path, to name a few.

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

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

发布评论

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

评论(1

混浊又暗下来 2024-07-17 06:22:23

我认为不可能将所有 .jar 压缩到一个 .jar 中。 其中许多 .jar 在其 .jar 文件(log4j.properties、spring XML 文件)中都有位于同一文件夹中的资源,因此会发生冲突。

最好提供启动脚本,可以通过设置类路径来启动应用程序。 我记得在 JDK1.5 或 1.6 中,您可以将一个文件夹设置为类路径,它将包含该文件夹中的所有 jar。

I don't think that is possbile to .zip all .jars into a single .jar. Many of these .jars have resources in their .jar file (log4j.properties, spring XML files) that are located in the same folder, so there will be clash.

Its better to provide start scripts that can start your application by setting the classpath. And I remember in either JDK1.5 or is it 1.6 you can set a folder as the classpath and it will include all jars from this folder.

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