任何人都可以識別下面的命名空間聲明有什麼問題嗎?我已經提到了所有的命名空間,並提供了對模式文件的引用。不知道還有什麼缺失。匹配的通配符是嚴格的,但是對於元素'tx:annotation-driven''context:component-scan'沒有發現聲明
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.mypackage" />
<context:annotation-config />
<tx:annotation-driven />
</beans>
錯誤消息: - CVC-復type.2.4.c:
在此行中發現多個註解的匹配通配符是嚴格的,但沒有聲明可以找到元素' TX:註解驅動的」。 - schema_reference.4:無法讀取模式文檔'http://www.springframework.org/schema/tx/spring-tx.xsd',因爲1) 找不到文檔; 2)文件無法閱讀; 3) 該文件的根元素不是
<xsd:schema>
。
聽起來像是日食問題 –
如果您無法訪問上述[spring-tx.xsd](http://www.springframework.org/schema/tx/spring-tx.xsd),則會發生這種情況。通過在Web瀏覽器中進行測試來測試您的訪問權限。我可以訪問該XSD,並且您的XML確實可以爲我成功驗證。 – kjhughes
如果不是這樣,請注意,[有些衝突版本的Spring jars導致類似於XSD訪問錯誤的錯誤](http://stackoverflow.com/a/29472455/290085)。 – kjhughes