【发布时间】:2019-01-02 02:53:04
【问题描述】:
我正在使用从messages.properties 读取的自定义@NotNull 消息为属性编写一些基本验证。这些消息可以很好地阅读,但是大部分默认 Spring 错误消息仍然如下:
"Validation failed for argument at index 0 in method: public java.lang.String uk.co.schedulerapi.Scheduler_Rest_Controller.bookAppointment(uk.co.apidefinitions.BookAppointment) throws java.lang.Exception, with 1 error(s): [Field error in object 'bookAppointment' on field 'windowStart': rejected value [null]; codes [NotNull.bookAppointment.windowStart,NotNull.windowStart,NotNull.java.lang.String,NotNull]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [bookAppointment.windowStart,windowStart]; arguments []; default message [windowStart]]; default message [windowStart parameter is required]] "
是否可以删除所有错误消息并保留我的自定义消息而不进行字符串解析?
【问题讨论】:
标签: java spring spring-boot error-handling