Description
Hi,
I am using:
- Spring Boot: 3.2.10
- Spring Framework: 6.1.13
- Hibernate Validator: 8.0.1.Final
I am using the default Spring Boot auto-configuration, there is no customization on the project. I have a Controller Advice that is inherent from org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
, and I want to use Problem Details as a response error format in my project.
1 - I need to customize my validation messages and interpolate some values. I am trying to follow the Spring Framework documentation. However following the documentation instructions I got the default messages from Bean Validation (in my language pt-BR).
2 - Then I tried to put the Spring codes on the annotations message attribute. I got the messages from the messages.properties
file but the arguments {0}, {1}, {2}, etc. do not were interpolated by Spring.
3 - Finally, I changed the strategy and resolved to use the Bean Validation interpolation format, I got the correct messages, but when Spring Boot tried to resolve the Problem Detail fields I got an unexpected exception.
The following project can be used to simulate the problems: spring-boot-bean-validation-message-interpolation-issue
Public
Three branches simulate the respective problems:
1 - spring-doc
2 - spring-doc-with-message
3 - bean-validation
I read the Spring documentation many times and debugged the project, but I did not find a way to make the project work as expected.
Let me know if I missed some steps to make Bean Validation work with Spring Boot and be able to customize my messages according to the official documentation.