最近一個java web工程中常出現xml文件的xsd驗證失敗信息,異常以下:java
Multiple annotations found at this line: - Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-3.0.xsd). For more information, right click on the message in the Problems View and select "Show Details..." - Referenced file contains errors (http://www.springframework.org/schema/tool/spring-tool-3.0.xsd). For more information, right click on the message in the Problems View and select "Show Details..." - Referenced file contains errors (http://www.springframework.org/schema/context/spring-context-3.0.xsd). For more information, right click on the message in the Problems View and select "Show Details..."
展開異常信息:web
The errors below were detected when validating the file "spring-beans-3.0.xsd" via the file "applicationContext-mongodb.xml". In most cases these errors can be detected by validating "spring-beans-3.0.xsd" directly. However it is possible that errors will only occur when spring-beans-3.0.xsd is validated in the context of applicationContext-mongodb.xml.
解決辦法就是將配置文件中的xsd文件的版本號去掉。spring
原文檔:mongodb
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
修改成:
app
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
就是將spring-context的xsd文件的版本號去了就能夠了。
this
參考:http://stackoverflow.com/questions/13693065/error-in-spring-application-context-schemacode