您的位置:首页 > 编程语言 > Java开发

Unable to locate Spring NamespaceHandler for XML schema namespace

2013-11-12 14:47 381 查看
blog转移到github:本文地址http://ssy341.github.io/myblog/spring/2014/03/31/Unable-to-locate-Spring-NamespaceHandler-for-XML-schema-namespace.html关键字:Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
这个异常花了不少时间,打jar包一直出问题,一开始以为是打包工具的原因,myeclipse下打,intellij下打,都是同样的错误,在网上搜索后,大部分都是英文资料,不能全懂,不能明白到底是什么问题,从几个中文资料得知是spring的两个什么文件,什么什么在打jar包的时候会覆盖怎么的,但是还是不解,这个问题工具应该是可以解决的,后面又想,项目是maven管理的,是不是打包的方式不一样呢?又尝试在网上搜索maven项目打包jar,得知要用【maven-assembly-plugin】这个东东,感觉有希望了,马上试试,结果还是不行,又隔几日,我再google,终于看到一个比较起眼的句子【It solved my problem. 】原地址:http://www.coderanch.com/t/547999/Spring/Configuration-Unable-locate-NamespaceHandler-namespace
从上文中可以得知在这个http://robert-reiz.com/2011/11/14/832/#comment-506里面可以找到解决方法,我连忙点进去,照着里面的一试,哎呀,终于可以了,真是柳暗花明又一村。虽然终于解决了问题,但是我始终不明白这样的做法,可能觉得这个方法不官方,不靠谱,如果有遇到同样问题的朋友,希望一起讨论下,这个到底是什么问题。
下面为我的maven配置代码:
<build>
<plugins>
<!-- <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.payplat.dacq.impl.AutoJob</mainClass>
</manifest>
</archive>
</configuration>

<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>-->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<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.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
加入上述配置后,然后在install,得到的jar包就是没有问题的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐