java - Maven 2 程序集插件破坏了一些 META-INF 文件

标签 java spring maven-2

我正在使用 Maven 2 程序集插件来构建带有依赖项的 jar 并生成可执行 JAR 文件。我的程序集包括 Spring 和 CXF 库。

CXF 包含 META-INF 文件 spring.schemas 和 spring.handlers 的副本,最终会破坏 spring-2.5.4 jar 中的类似文件。

我可以手动更新 jar-with-dependencies 中的这两个文件。

我正在寻找的是 Maven POM 中的某种方法来指导程序集插件获取这两个文件的正确版本。

程序集插件文档谈论了文件过滤,但似乎没有配置或参数,无需麻烦地创建自定义程序集描述符。

在这种情况下,制作自定义程序集描述符是我唯一的希望吗?

最佳答案

出于某种原因,Mojo 和其他人建议的解决方案仍然对我不起作用。我创建了自定义 spring.handlersspring.schemas 文件,并将它们放在 src/main/resources/META-INF 下。但是,当使用 unpackOptions 时,我的文件也不包含在内。当我不使用 unpackOptions 时,我的文件不是 jar 中的文件。

我最终所做的是直接引用这些文件。这最终将我的文件放入 JAR 中。

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <!-- TODO: a jarjar format would be better -->
    <id>jar-with-dependencies</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <dependencySets>
        <dependencySet>
            <outputDirectory>/</outputDirectory>
            <unpack>true</unpack>
            <unpackOptions>
                <excludes>
                    <exclude>META-INF/spring.handlers</exclude>
                    <exclude>META-INF/spring.schemas</exclude>
                </excludes>
            </unpackOptions>
            <scope>runtime</scope>
        </dependencySet>
    </dependencySets>
    <files>
        <file>
            <source>${project.basedir}/src/main/resources/META-INF/spring.handlers</source>
            <outputDirectory>META-INF</outputDirectory>
        </file>
        <file>
            <source>${project.basedir}/src/main/resources/META-INF/spring.schemas</source>
            <outputDirectory>META-INF</outputDirectory>
        </file>
    </files>
</assembly>

关于java - Maven 2 程序集插件破坏了一些 META-INF 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/971158/

相关文章:

java - 在背景不透明的 PDF 上创建条形码叠加层 (iText)

java - Spring Autowiring 父类字段的最佳方法是什么?

javascript - 将 AngularJS 与 SpringMVC 结合使用 - 为什么以及如何?

maven-2 - 下载快照工件时,Maven 将 '-windows' 添加到工件名称中

maven-2 - 如果发生单元测试失败,Maven 报告插件不会执行

java - 解析巨大的 xml 文件以从子标签中获取不同的值 - 需要最佳方法建议

java - 我如何修改这个字符串并从 java 中的 JSON 对象获取我想要的值?

java - 找不到@EnableSwagger 注释

maven-2 - Maven : How to install a plugin in offline mode

java - 当只有按钮对象具有 .addActionListener 时,为什么此代码中的 JFrame 会对 ActionEvents 使用react?