spring-boot: spring boot unable to interpolate message for jsr-303 validation
if I define the following validation messages,
@Size(min = 3, message = "{validation.account.name}")
private String name;
I expect spring boot would read from messages*.properties from classpath and find the validation.account.name key to interpolate the message, but it just shows {validation.account.name} on the page.
This https://github.com/Zane-XY/springboot-i18n-problem demos the problems.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 7
- Comments: 29 (10 by maintainers)
Commits related to this issue
- Provide a way to to interpolate message for JSR-303 validation. see gh-3071 — committed to nosan/spring-boot by nosan 5 years ago
- Provide a way to to interpolate message for JSR-303 validation see gh-3071 — committed to nosan/spring-boot by nosan 5 years ago
- Provide a way to to interpolate message for JSR-303 validation see gh-3071 — committed to nosan/spring-boot by nosan 5 years ago
- Provide a way to to interpolate message for JSR-303 validation see gh-3071 — committed to nosan/spring-boot by nosan 5 years ago
- Provide a way to to interpolate message for JSR-303 validation see gh-3071 — committed to nosan/spring-boot by nosan 5 years ago
- Provide a way to to interpolate message for JSR-303 validation see gh-3071 — committed to nosan/spring-boot by nosan 5 years ago
IMHO it should be easy to implement, like this:
It works.
To get it worked I have to move validation keys into the file ValidationMessages.properties while all oder messages reside in messages.properties.
FYI.
Solved by add
ValidationMessages.propertiesin classpath. this file is used by JSR303 implementation.Overriding the auto-configured
Validatorand setting theMessageSourceworks for me.ValidationConfig.java
Person.java
messages.properties