【问题标题】:Spring 3 NamespaceHandler issues with Maven Shade pluginMaven Shade 插件的 Spring 3 NamespaceHandler 问题
【发布时间】:2012-05-22 00:30:43
【问题描述】:

带有 Apache Maven 3.0.3 和 Maven Shade 插件 1.6 的 Spring 3.1.1.RELEASE。

使用 mvn shade 插件将工件打包到 uber-jar 中,包括其依赖项:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
        <phase>package</phase>
        <goals>
            <goal>shade</goal>
        </goals>
        <configuration>
            <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                    <mainClass>com.MyApplication</mainClass>
                </transformer>
            </transformers>
        </configuration>
    </execution>
</executions>

似乎打包很好,但在执行时抱怨 Spring NamespaceHandler 问题:

Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/util]
Offending resource: class path resource [spring/test-context.xml]

这适用于 util 和 p-命名空间,但不限于这些:

xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"

如果我以手写方式重写属性或列表 (util),问题就会消失。

【问题讨论】:

    标签: spring maven maven-3 spring-3 maven-shade-plugin


    【解决方案1】:

    尝试将AppendingTransformer 添加到您的配置中。该示例特别提到这对 Spring 处理程序很有用。

    【讨论】:

    • 这对我也有帮助,不适用于 maven-assembly-plugin,不适用于阴影,但适用于您的答案。请您解释一下这里发生了什么以及为什么会这样?
    猜你喜欢
    • 2017-08-27
    • 2014-07-23
    • 2015-02-05
    • 2011-05-10
    • 2015-08-20
    • 2013-02-11
    • 2015-02-04
    • 1970-01-01
    • 2021-12-13
    相关资源
    最近更新 更多