关于MongoDB无故出错 cvc-complex-type.2.4.a: Invalid .. element 'mongo:client-options'.
项目以前正常启动,并未改动其相关功能文件,出错:
(前提是保证没有标签写错,少写或写错逗号、标签结尾符等低级错误,在以前正确无误的情况下突然某天报错)
target/classes/spring-mongo.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 46; cvc-complex-type.2.4.a: Invalid content was found starting with element 'mongo:client-options'. One of '{"http://www.springframework.org/schema/data/mongo":client-settings}' is expected.
言下之意是 mongo:client-options 标签下属性出错,可能不存在或属性改变。
究其原因,发现 beans 标签引入的 xmlns:xsi mongo为 https://www.springframework.org/schema/data/mongo/spring-mongo.xsd
未指定版本号,其默认使用最新版本,版本升级导致属性改变,
进入:http://www.springframework.org/schema/data/mongo/ 验证版本及更新时间
解决方式:指定上一版本或以前版本号
如:https://www.springframework.org/schema/data/mongo/spring-mongo-2.2.xsd
即可解决