2017-02-10 102 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)「