@Pattern(regexp = "{A-Za-z0-9}*")
private String name;
Above regex, I want to read from the property file
This is possible from Spring 3.0.1 afterwords. You can do it like a regular property value binding. Inside your application.yml
my:
regex:
charOrNumber: '{A-Za-z0-9}*'
And then in your Java class:
@Pattern(regexp = "${my.regex.charOrNumber}")
"${your.config.key:-default value}". Have you tried that and it does not work or haven't you tried it and don't know about it?