记录一次根据spring官网的例子,自定义编写xml发生的错误

网址:https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#xml-custom
章节:10.2. XML Schema Authoring

按照spring官网的例子一步步测试,步骤如下:

1、编写xsd文件【myns.xsd】
2、编写NamespaceHandler【MyNamespaceHandler 】
3、编写BeanDefinitionParser【SimpleDateFormatBeanDefinitionParser 】
4、编写META-INF/spring.handlers
5、编写META-INF/spring.schemas
6、在application.xml文件中引入名称空间

//```xml

<?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:myns=“http://www.mycompany.example/schema/myns”
xsi:schemaLocation="
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd

    // 重点就是这里。按这里的写法会一直按照网址去网上下载不会使用本地的,然而又下载不到,所以一直报错
    http://www.mycompany.example/schema/myns http://www.mycompany.com/schema/myns/myns.xsd">

<!-- as a top-level bean -->
<myns:dateformat id="defaultDateFormat" pattern="yyyy-MM-dd HH:mm" lenient="true"/> 

<bean id="jobDetailTemplate" abstract="true">
    <property name="dateFormat">
        <!-- as an inner bean -->
        <myns:dateformat pattern="HH:mm MM-dd-yyyy"/>
    </property>
</bean>
```

解决:
1、在网上找了别的例子试了试,是成功的
2、比对官网的例子和网上给的例子
3、找到问题

http://www.mycompany.example/schema/myns http://www.mycompany.com/schema/myns/myns.xsd

替换为
http://www.mycompany.example/schema/myns http://www.mycompany.com/schema/myns.xsd

思考:
1、既然一直去网上去下载,那么就只需要对比http://www.mycompany.com/schema/**myns.xsd的差异就可以了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Fire Fish

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值