java - spring-beans.xsd 没有定义 "local"。为什么?

几乎每个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 validator 仅使用 Internet 链接并显示 xml 错误,更具体地说:

“cvc-complex-type.3.2.2:属性'local'不允许出现在元素'ref'中”

这是一个错误吗?

编辑: 根据要求,这是我的 Spring 头:

<?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">

编辑 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" />

最佳答案

您应该尝试使用 <ref bean="someBean"/>反而。

关于java - spring-beans.xsd 没有定义 "local"。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21054171/

相关文章:

java - 比较 SpEL 中的枚举

java - 如何强制 Spring 容器不返回 bean 的单例实例?

java - 无法将 boolean 值设置为 null

java - 在 Spring MVC 中将 ContextLoaderListener 添加到 w

java - 从另一个异步方法调用的 Spring 异步方法

java - 避免来自 swagger api 的默认基本错误 Controller

java - 在 Spring Boot 应用程序中安排任务的最佳方法是什么

java - 为什么来自 Spring 的 BCryptPasswordEncoder 为相同的输入

java - Spring MVC - AngularJS - 文件上传 - org.apache.

spring - 在 spring 上下文中定义一个字符串