所以我想改變用於通過DropWizard資源來驗證模型的驗證消息。覆蓋DropWizard ConstraintViolation消息
我正在使用java bean驗證註釋。例如,這裏是我想要驗證的字段之一:
@NotEmpty(message = "Password must not be empty.")
我可以按照預期使用驗證器來測試此工作。
然而,當我使用DropWizard做資源上的驗證,加入了一些額外的東西到該消息。我看到的是這樣的 - password Password must not be empty. (was null)
我發現的代碼,這是否在這裏 - https://github.com/dropwizard/dropwizard/blob/master/dropwizard-validation/src/main/java/io/dropwizard/validation/ConstraintViolations.java
特別是這種方法 -
有什麼辦法,我可以覆蓋這個行爲?我只是想顯示我的註釋設置消息...
我喜歡[盧卡斯Wiktor的的答案](http://stackoverflow.com/a/30799426/1891566)更好,因爲他重新instates其他異常映射器說的這第一步答案刪除,有效地改變* ConstraintValidationException *的映射器* – 2016-02-23 17:43:35