SPRING指定加载本地xsd约束

                             哈哈,大家好,我是一名小小程序员,今天开始我也开始写博客了,~因为知识取自于互联网,所有想把自己的一些小经验写出来回馈大家,!

 

情景:

<?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:mvc="http://www.springframework.org/schema/mvc"
  xmlns:p="http://www.springframework.org/schema/p"
  xmlns:context="http://www.springframework.org/schema/context"
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
  xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://www.springframework.org/schema/mvc
          http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
           http://code.alibabatech.com/schema/dubbo  
       http://code.alibabatech.com/schema/dubbo/dubbo.xsd"  
  default-autowire="byName">

写了一个程序打成jar包 倒出来后报错 dubbo:application  这个约束找不到, 原因是http://code.alibabatech.com/schema/dubbo 约束的网站已经停了,淘宝已经关闭了这个网站,

那么把dobbo.xsd这个约束下载下来 放到本地如何 让spring加载本地呢?

   解决方法:

       其实spring是做的很贴心的,他默认是先加载本地的,你打开它的源码包META-INF 下 会发现2个文件,

spring.handlers  ,spring.schemas  这2个文件

例如spring.schemas 指定这个本地的xsd在哪个目录下, 

spring.handlers  指定处理这个头信息的java类是哪个,

 

在spring-core.jar的META-INF下 spring.handlers 加上一行http\://code.alibabatech.com/schema/dubbo=com.alibaba.dubbo.config.spring.schema.DubboNamespaceHandl

在spring.schemas  加上一行http\://code.alibabatech.com/schema/dubbo/dubbo.xsd=META-INF/dubbo.xsd 

成功解决这个问题!

 

QQ 283398689   欢迎来讨论!,还求有hadoop方面的高手来加我 多多指导!

 

 

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值