平时,在使用spring过程中,经常会遇到一些莫名其妙的validate报错。比如下面的:
Multiple annotations found at this line:
- schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/security/spring-
security-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>.
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'http'.
这样的类似的报错,解决方法都应该相同。
首先推荐看一篇csdn上关于spring载入xsd命名空间的文章:http://blog.csdn.net/bluishglc/article/details/7596118
我这里简单总结一下解决这类问题的方法:
1.报这类错误经常的原因是没有导入对应的jar包。如果你不确定,可以找下相关的jar包中是否有对应的xsd文件。
2.如果上面确认有xsd文件,确定你spring xmlns引入的版本在jar包中有。否则更正版本。
经过上面两步正常应该已经可以解决,原因,以及一些小技巧,可以参考上面的文章。
下