在DUBBO项目中 配置文件出现找不到标签而报红叉 但项目能够正常运行

使用dubbo 项目的同学,大概都遇到过dubbo 配置文件出现错误的情况,但是项目又能够正常运行。

在eclipse 中错误如下:

在DUBBO项目中 配置文件出现找不到标签而报红叉 但项目能够正常运行

- 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>

原因:eclipse 在校验xml 文件 找不到 dubbo的xsd文件。

解决方式:eclipse  windows  -   Preferences   -   XML  -    XML Catalog  点击Add添加  如下图:

在DUBBO项目中 配置文件出现找不到标签而报红叉 但项目能够正常运行

如下图:在弹出框中  location:中找到 本地的dubbo.xsd 文件 。如图三,

                                  key:添加dubbo配置引用的地址。如图四,

在DUBBO项目中 配置文件出现找不到标签而报红叉 但项目能够正常运行

图三:

解压dubbo.jar 包 。找到dubbo.xsd  。copy 放到 一个文件夹 中(随意放,方便图二location设置)。。我是放到了d:\xsd文件夹

在DUBBO项目中 配置文件出现找不到标签而报红叉 但项目能够正常运行

图四: key 设置的值要和配置文件中的一样。

在DUBBO项目中 配置文件出现找不到标签而报红叉 但项目能够正常运行