Unable to locate Spring NamespaceHandler for XML schema namespace :dubbo 報錯

dubbo項目報錯:

 Unable to locate Spring NamespaceHandler for XML schema namespace [http://dubbo.apache.org/schema/dubbo]

dubbo依賴配置:

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <version>2.5.3</version>
        </dependency>

dubbo.xml配置

<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
       xmlns="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
       http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">

原因就是dubbo的jar包和xml中使用的對應的命名空間不匹配。

因爲dubbo已經捐獻給了apache,但是alibab的dubbo包類依然在各大maven倉庫。但是通常我們開發時都會去[dubbo官網](http://dubbo.apache.org/en-us/) 去查看資料,但是所有資料已經是apache相關的命名,包含dubbo源碼的package名稱。

解決:

將xml中的dubbo的xsd改下:

xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"

改成:

xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"

http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd 

改成

<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xmlns="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
       http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章