Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 用Jaxb解组数字忽略实类型_Java_Xml_Jaxb - Fatal编程技术网

Java 用Jaxb解组数字忽略实类型

Java 用Jaxb解组数字忽略实类型,java,xml,jaxb,Java,Xml,Jaxb,我有一个类,其字段类型为Number。我使用它是因为它可以是一个双精度或整数 XML生成似乎很好,它包含此字段的实际类: <thresholdValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:double">0.2</thresholdValue> 在解组时,我有一个例外: javax.xml.bind.UnmarshalException: Unable to create an instan

我有一个类,其字段类型为Number。我使用它是因为它可以是一个双精度或整数

XML生成似乎很好,它包含此字段的实际类:

<thresholdValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:double">0.2</thresholdValue>
在解组时,我有一个例外:

javax.xml.bind.UnmarshalException: Unable to create an instance of java.lang.Number

我正在使用JAXB 2.2.11和Java 7。

xsi前缀声明是否正确?在我看来像是个bug。@是的,它是在包含以下内容的对象中声明的:xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance. 我将我的对象简化为一个没有其他对象和父类的单一对象。但结果是一样的。
javax.xml.bind.UnmarshalException: Unable to create an instance of java.lang.Number