- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我有一个 spring.xml 定义如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="triangle" class="org.tutorial.spring.Triangle">
<property name="pointA">
<idref bean="pointA"/>
</property>
<property name="pointB" ref="pointB"/>
<property name="pointC" ref="pointC"/>
</bean>
<bean id="pointA" class="org.tutorial.spring.Point">
<property name="x" value="0"/>
<property name="y" value="0"/>
</bean>
<bean id="pointB" class="org.tutorial.spring.Point">
<property name="x" value="100"/>
<property name="y" value="200"/>
</bean>
<bean id="pointC" class="org.tutorial.spring.Point">
<property name="x" value="-100"/>
<property name="y" value="-200"/>
</bean>
</beans>
Point
类基本上是一个有 2 个私有(private) int 成员的类。我的问题是我在 IDREF 上收到如下错误:
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'org.tutorial.spring.Point' for property 'pointA';
nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.tutorial.spring.Point] for property 'pointA': no matching editors or conversion strategy found
据我了解,bean PointA
的IDREF(在上述情况下)的目的是bean三角形存在(错误检查)。所以我确实在 IDREF 元素中提供了 bean PointA
(string) 的名称。为什么我会收到上述错误?
当我认为它只是通过提供其名称来检查 bean (PointA
) 的存在时,为什么它试图将字符串转换为 Point?
我真的很困惑。请帮忙。谢谢。
最佳答案
idref
用于传递一个bean(即String)的名称(标识符)。
<idref bean="pointA">
与字符串值 pointA
完全相同,除了如果没有定义这样的 bean,Spring 会报错。
见 the Spring documentation了解详情。
要传递实际的 bean,只需使用 ref
,就像你对 pointB
所做的一样和 pointC
.
关于Spring IDREF 使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14607142/
根据其架构验证我的 XML 文件时,我收到此错误消息。谁能建议可能出了什么问题? XML 文件是: Al Frank Smith Henry Smith 架构是:
XSD中IDREF和IDREFS有什么区别? 我知道它们都引用了 ID 属性,但有什么区别?什么时候使用它们? 最佳答案 IDREF 类型的属性是对其他具有 ID 类型属性的元素的引用。 IDREFS
我正在编写一个 XML 文档并试图说明它的规范。 我认为我可以指定一个标签的属性可以限制为另一个标签的属性,我认为可以使用 !ATTLIST 的 IDREF,但我不太确定。示例:
我有一个 spring.xml 定义如下: Point 类
我使用的是标准 xml 模式,称为 isosts,我需要使用 jaxb 将模式转换为 java 类。在此 xml 架构中,许多元素的属性 rod 类型为 xs:IDREFS 。 Jaxb 将 xs:
鉴于 spring.xml 的以下代码,它发现 idref 有问题......请解释一下
我最终成功地摆弄了 HyperJAXB,以便当 XSD 具有复杂类型 A 并且具有复杂类型 B 的 IDREF 时,HyperJAXB 将在两个生成的实体之间生成 @OneToOne JPA 注释。
我正在阅读和测试 XQuery 以及我使用 BaseX(www.basex.org) 和 saxon-HE 9.4.0.6N 的类似测试工具。 对于以下简单的 XML 文件 - 没有附加到 sampl
我有这样的元素 当电机元件在当前文档中时,它工作正常。 但是当我想从另一个文件导入电机元素时 Intell
有没有一种简单的方法可以使用 IDREF 属性来引用不同 XML 文档中的元素?如果没有,关于如何以不同方式做的任何建议?我想做的是为桌面 RPG 制作数字字符表,我希望包含所有字符特定信息的 XML
我为我的 xml 元素使用全局唯一标识符 (GUID),架构如下所示: 和这样的 xml 元素: 对应的 xsd 架构: 我想在另一个元素
给定一些示例 data.xml 文件: Google
我有一个 XML 架构:-
W3C XSD 1.0 Part 2: Datatypes规范是指 W3C XML 1.0 ID 和 IDREF 类型的定义规范,但这些文档都没有定义对这些类型值的长度的任何限制。 但是,似乎某些 X
我对 XSD 设计和 JAXB 都是新手。我成功创建了 XSD,如下所示:
我正在使用 xjc 从 XML 模式生成 Java 对象。我想使用 IDREF 在文档中多次引用相同的元素。我还想将 IDREF 引用的对象限制为特定类型。我想这样做是为了模式验证,但也是为了在 Ja
我正在寻找一个 XSD,它将用于通过 JAXB 生成一些 Java 类。我希望生成的 XML 看起来像这样: Bob Smith Some Appointment Type
我有一个如下所示的 XML 结构: [...] id_1001_0 23 Apple [...] 我想使用 Linq to XML 将其读入(非匿
我应该如何在 XMLSchema 中使用 ID/IDREFS,以便通过 xsl:key 和 xpath 函数 key() 和 id() 将它用于 XSL 转换? 如果我使用下面的 DTD 一切都很好
]> Snow Crash Neal Stephenson JDom 是否有能力执行以下操作: Element root
我是一名优秀的程序员,十分优秀!