Spring 3.1.1.RELEASE,带有Apache Maven 3.0.3和Maven Shade插件1.6。
使用mvn shade插件将 Artifact 打包在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),问题将消失。
最佳答案
尝试将AppendingTransformer添加到您的配置中。该示例特别提到了这一点对于Spring处理程序很有用。
关于Maven Shade插件的Spring 3 NamespaceHandler问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10584752/