spring 4.0 不再支持ref local标签

本文介绍在Spring 4.0中使用<ref>元素时,local属性已被弃用。若继续使用需将xsd指向3.2版本,或改为使用<ref bean="bean名称">的形式。这是由于local属性不再提供额外价值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天配置bean时顺手写了

 <ref local="xxxxx">

结果报错,attribute local is not allowed here

感到很奇怪,看了一下,spring 4.0不再支持 ref local 了。
如果想继续使用的话将xsd 指向 3.2,
xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd“>

当然官方推荐 使用

<ref bean="xxxxx">

The local attribute on the ref element is no longer supported in the 4.0 beans xsd since it does not provide value over a regular bean reference anymore. Simply change your existing ref local references to ref bean when upgrading to the 4.0 schema.

地址:http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值