【发布时间】:2016-04-19 04:28:38
【问题描述】:
谁能找出下面的命名空间声明有什么问题?我已经提到了所有的命名空间并给出了对模式文件的引用。不知道还缺少什么。
<?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-complex-type.2.4.c:匹配通配符是严格的,但找不到元素'tx:annotation-driven'的声明。 - schema_reference.4:无法读取架构文档“http://www.springframework.org/schema/tx/spring-tx.xsd”,因为 1) 找不到文件; 2) 文件无法读取; 3) 文档的根元素不是
<xsd:schema>。
【问题讨论】:
-
听起来像是 Eclipse 问题
-
如果您无法访问提到的spring-tx.xsd,就会发生这种情况。通过在 Web 浏览器中打开它来测试您的访问权限。我可以访问该 XSD,并且您的 XML 确实为我成功验证。
-
@kjhughes.. 谢谢。我试过你的建议,但没有帮助。我也可以访问 XSD。我终于放弃了,只是关闭了 XML 验证。