几乎每个spring项目都使用spring-beans.xsd(指的是更精确).但是,如果您查看该文件,http://www.springframework.org/schema/beans/spring-beans.xsd,您将看到它是版本3.2,并且没有属性"local"的定义".
更有趣的是,http://www.springframework.org/schema/beans/spring-beans-3.2.xsd确实定义了"本地".
此外,由于spring.schema,文件被从jar(org/springframework/beans/factory/xml/spring-beans-3.2.xsd)中拉出,我认为任何项目都不会有编译或运行时问题.
另一方面,我认为Eclipse的xml验证器仅使用互联网链接并显示xml错误,更具体地说:
"cvc-complex-type.3.2.2:属性'local'不允许出现在元素'ref'中"
这是一个错误吗?
编辑:根据请求,这是我的春天标题:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd">
Run Code Online (Sandbox Code Playgroud)
编辑2:这是我在使用本地的地方
<bean id="bar"
class="org.springframework.batch.item.support.CompositeItemWriter">
<property name="delegates">
<list>
<ref local="foo" />
</list>
</property>
</bean>
<bean id="foo" class="java.lang.String" />
Run Code Online (Sandbox Code Playgroud)