今日我们开发遇到spring的xsd文件打包的时候,丢失了,导致无法启动,
rg.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 33; schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/context/spring-context-3.1.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
最后的解决方案是废弃assembly打包插件,使用shade。
原因见 http://blog.csdn.net/leonzhouwei/article/details/9978771
插件代码如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.jd.payment.risk.benz.qpay.daylimt.DaylimitAmountTopology</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
来源:oschina
链接:https://my.oschina.net/u/109139/blog/177793