项目中需要使用阿里的dubbo,开发中发现Failed to read schema document ‘http://code.alibabatech.com/schema/dubbo/dubbo.xsd’。上网百度发现别人说阿里开源网站http://code.alibabatech.com,挂掉有好几个月了,距离现在一年多了,然后在代码中按住ctrl将鼠标悬停在网址上进行访问发现的确访问不了。
报错:
Multiple annotations found at this line:
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'.
- schema_reference.4: Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.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>.
Spring配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
我们都知道Spring在启动时是要检验XML文件的,而Spring在加载dubbo时,会从dubbo的jar里加载dubbo.xsd
缺少这个文件所以xml验证会报错。
解决方案:
进入maven 的仓库 com/alibaba/dubbo 解压dubbo-2.5.3.jar
在dubbo-2.5.3文件夹下面的META-INF 里面有dubbo.xsd.
第四步点击File system选中本地dubbo.xsd文件即可。
配置成功后选中spring的配置文件,选择validate,进行xml重新验证。