Jersey ValidationException 消息并不总是相同的

Jersey ValidationException message not always the same

在我正在研究的 API 中,我有以下定义:

@PUT
@Path("/{messageTypeId}")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@ApiOperation(value = "Amend the Message Type.", notes = "Amend the Message Type.", tags={  })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "Successful response.", response = Void.class),
    @ApiResponse(code = 400, message = "Bad Request.", response = Problem.class),
    @ApiResponse(code = 404, message = "Not Found.", response = Problem.class),
    @ApiResponse(code = 500, message = "Internal Server Error.", response = Problem.class),
    @ApiResponse(code = 503, message = "Service Unavailable.", response = Problem.class) })
void amendMessageType_(@PathParam("messageTypeId") @Size(max=255) @ApiParam("Message Type Unique Identifier") String messageTypeId,@Valid MessageTypeAmendBody messageTypeBody) throws Exception;

发生 ValidationException 时有一个 ExceptionMapper,用于捕获并在 JSON 中格式化错误。似乎映射器有时会收到这样的消息:

arg0 is not correct, must be between 0 and 255

有时

messageTypeId is not correct, must be between 0 and 255

当我 运行 来自 IntelliJ(我得到第一个)和 Maven(第二个)的单元测试或者当我 运行 应用程序(一个或另一个) )...你有什么想法吗?

谢谢!

为了解决这个问题,我不得不添加一个编译标志:

<compilerArgs>
    <arg>-parameters</arg>
</compilerArgs>

到 Maven 编译器插件。