1. 程式人生 > >關於dubbo創建服務和引用服務時,會報錯:cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 問題的解決

關於dubbo創建服務和引用服務時,會報錯:cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 問題的解決

一個 sch 系統 contex ips 分布 配置文件 prot 商城項目

  在跟著做淘淘商城項目時,用到了dubbo,作為一個SOA架構的項目,分為表現層與服務層,自然地,為了各個層之間解耦合(或者最大限度地松耦合),我們使用了dubbo這樣一個alibaba開源的分布式服務框架,該框架最大的特點就是利用分層的方式來架構,從服務模型的角度來看,Dubbo采用的是一種非常簡單的模型,要麽是提供方提供服務,要麽是消費方消費服務,所以基於這一點可以抽象出服務提供方(Provider)和服務消費方(Consumer)兩個角色。

  但是在appplicationContext-service.xml創建服務和在springmvc.xml中引用服務時,我們設置了dubbo約束,但是仍然會報錯,系統提示我們找不到dubbo:application、dubbo:registry、dubbo:protocol、dubbo:reference等元素

  具體錯誤如下:

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

  錯誤如下圖所示:

  技術分享圖片

  技術分享圖片

  為什麽呢?因為阿裏的開源網站http://code.alibabatech.com,早已經掛掉了!!!

  這就說明系統沒有找到dubbo.xsd,於是我手動添加dubbo.xsd約束文件。在下載的dubbo-2.5.3.jar包中存在一個文件dubbo.xsd,將此文件取出存放於電腦的磁盤的某一目錄,配置加載的時候先加載本地的。如下配置即可解決。

  技術分享圖片

  技術分享圖片

  在Eclipse中 Window --> Preferences

  技術分享圖片

  技術分享圖片

  保存完成後,右鍵相應的報紅的配置文件,選擇validate。稍等片刻即可解決。

  技術分享圖片

參考鏈接:

  https://www.cnblogs.com/yuanchaoyong/p/9758053.html

  https://blog.csdn.net/wxydaisy/article/details/40650405

關於dubbo創建服務和引用服務時,會報錯:cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 問題的解決