maven-assembly-plugin的问题:
你写了:
I also use the maven-assembly-plugin to create a executable jar file.
啊……我猜maven-assembly-plugin是造成这个问题的原因.这是因为模式解析机制以这种方式工作:Spring提供带有jar的XSD文件.在jar中,文件夹META-INF是一个文件schema.info.此文件包含所有XSD fiels的列表以及此jar提供的位置(在jar中).
例如:spring.sug of spring-beans-3.1.1.RELEASE.jar
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd
http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd
http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd
http://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd
http://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd
http://www.springframework.org/schema/tool/spring-tool-3.1.xsd=org/springframework/beans/factory/xml/spring-tool-3.1.xsd
http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.1.xsd
http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd
http://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd
http://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd
http://www.springframework.org/schema/util/spring-util-3.1.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd
http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd
所以现在你有不同的jar(spring-bean,spring-tx,spring-aop,spring-context …),它们都包含一个META-INF / spring.schemas文件,内容不同.另一方面,您使用maven-assembly-plugin在一个jar文件中聚合所有jar文件的内容.
我猜你也会遇到spring.handlers文件的这个问题.
看起来您可以配置maven-assembly-plugin来合并这些文件.见:this answer的this answer
另一种解决方案是使用spring-boot-maven-plugin而不是maven-assembly-plugin
(或使用maven-shade-pluging)