首页 文章

Spring 3 NamespaceHandler与Maven Shade插件有关

提问于
浏览
7

Spring 3.1.1.RELEASE与Apache Maven 3.0.3和Maven Shade插件1.6 .

使用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),问题就会消失 .

1 回答

  • 20

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

相关问题