2017-02-10 101 views
0

我正在使用Camel Rest DSL构建我的休息服务,但似乎它不识别JsonProperty注释。Camel Rest DSL无法识别JsonProperty访问

我有这样一个属性格式:

class Test { 

    private int id; 

    @JsonProperty(access = Access.READ_ONLY) 
    private String text; 
} 

,其余的定义是:

<rests xmlns="http://camel.apache.org/schema/spring"> 
    <rest consumes="application/json" produces="application/json" path="/api/v1"> 
     <post bindingMode="json" type="Test" uri="/path"> 
      <route> 
       ..... 
      </route> 
     </post> 
    </rest> 
</rests> 

当我把它用:

{ 
    "id":2, 
    "text":"asd" 
} 

文本字段也越来越初始化。

我缺少什么?

THX

回答

0

有杰克逊的@JsonProperty(访问= Access.READ_ONLY)的错误。 欲了解更多信息,请参阅:https://github.com/FasterXML/jackson-databind/issues/935

有在错误报告中提到的两种解决方法:

  • “可以帮助的唯一的事情就是创建一个setter和与@JsonIgnore标注为”
  • “ @JsonIgnoreProperties(value =“some_field”,allowGetters = true,allowSetters = false)“