org.codehaus.jackson.map.JsonMappingException:属性" matchColumn":com.sun.rowset.JdbcRowSetImpl的冲突setter定义

时间:2017-11-22 12:46:48

标签: java json jdbc jackson

我正在使用Jackson反序列化com.sun.rowset.JdbcRowSetImpl类的对象:

public class Main {

static String jsonInput = "{\"@class\":\"com.sun.rowset.JdbcRowSetImpl\", \"dataSourceName\":\"ldap://localhost:10389/ldap://localhost:10389/cn=apartment16,dc=example,dc=com\", \"autoCommit\":true}";


      public static void main(String[] args) throws Exception{
          ObjectMapper mapper = new ObjectMapper();
          mapper.enableDefaultTyping();
          Object o = mapper.readValue(jsonInput, JdbcRowSetImpl.class);
          System.out.println(o.getClass());
      }
  }

但我得到以下例外:

Exception in thread "main" org.codehaus.jackson.map.JsonMappingException: Conflicting setter definitions for property "matchColumn": com.sun.rowset.JdbcRowSetImpl#setMatchColumn(1 params) vs com.sun.rowset.JdbcRowSetImpl#setMatchColumn(1 params)
at org.codehaus.jackson.map.deser.StdDeserializerProvider._createAndCache2(StdDeserializerProvider.java:346)
at org.codehaus.jackson.map.deser.StdDeserializerProvider._createAndCacheValueDeserializer(StdDeserializerProvider.java:321)
at org.codehaus.jackson.map.deser.StdDeserializerProvider.findValueDeserializer(StdDeserializerProvider.java:167)
at org.codehaus.jackson.map.deser.StdDeserializerProvider.findTypedValueDeserializer(StdDeserializerProvider.java:188)
at org.codehaus.jackson.map.ObjectMapper._findRootDeserializer(ObjectMapper.java:2820)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2719)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1854)
at test.Main.main(Main.java:25)
Caused by: java.lang.IllegalArgumentException: Conflicting setter definitions for property "matchColumn": com.sun.rowset.JdbcRowSetImpl#setMatchColumn(1 params) vs com.sun.rowset.JdbcRowSetImpl#setMatchColumn(1 params)
at org.codehaus.jackson.map.introspect.POJOPropertyBuilder.getSetter(POJOPropertyBuilder.java:198)
at org.codehaus.jackson.map.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:1056)
at org.codehaus.jackson.map.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:654)
at org.codehaus.jackson.map.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:583)
at org.codehaus.jackson.map.deser.StdDeserializerProvider._createDeserializer(StdDeserializerProvider.java:432)
at org.codehaus.jackson.map.deser.StdDeserializerProvider._createAndCache2(StdDeserializerProvider.java:341)
... 7 more

我想这是因为杰克逊并不知道它应该用于哪个二传手?#34; matchColumn" (其中有4个)。但我不知道为什么它甚至试图设置这个领域,因为我没有宣布任何" matchColumn" JSON中的属性...... 有什么想法吗?

1 个答案:

答案 0 :(得分:1)

问题解决了:我使用的是旧版杰克逊。 2.7版本适用于我