我有一个使用 Spring Boot 2.1.9 和 RestTemplate 的 Maven 项目,当我使用 RestTemplate.exchange 方法时,它显示“由于带有 xsi:nil 的 xml 标记,无法在运行时反序列化 'java.lang.Long' 的实例”是的”。
class Pojo {
private List<Long> values;
}
xml:
<?xml version="1.0" encoding="utf-8"?>
<PojoResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/">
<values>
<value>10</value>
<value xsi:nil="true" />
<value>20</value>
</values>
</PojoResponse>
最佳答案
我解决了这个问题,包括 jackson-dataformat-xml、jackson-core 和 jackson-databind 版本 2.10.0 对 pom.xml 的依赖关系。
关于xml - 如何反序列化java Long哪个xml标签有xsi :nil?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58276842/