【发布时间】:2014-01-30 00:11:20
【问题描述】:
几乎每个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 验证器仅使用 Internet 链接并显示 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">
编辑 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" />
【问题讨论】:
-
请向我们展示您尝试使用 Eclipse 验证的 XML。编辑您的问题。
-
如果你去springframework.org/schema/beans .. 你会发现版本根本不重要。
-
@Ashish 你是什么意思版本无关紧要?这甚至不是我的问题。我说的是两个文件,在这种情况下,spring-beans.xsd 和 spring-beans-3.2.xsd 说它们是相同的版本,但一个定义了“本地”属性,另一个没有。
-
如果这是一个答案,我会把它放在答案部分。那是一条评论,我的意思是如果转到该链接并在最后三个文件中查找版本,您会找到相同的版本。所以看起来“本地”属性在当前版本中不再存在。
-
请在您尝试使用
local的位置发布。