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