I have spent hours trying different ways of providing a custom MessageInterpolator, however Spring is not allowing it.

I have a simple service that uses embedded config server. I want to provide a custom MessageInterpolator so I did the following bean config:

SpringBoot Cannot override message interpolation with JSR-303

I followed the spring reference docs that says all I need to do is provide this bean and customize it for validation customization.

While debugging, I see that spring's version of the bean always replaces mine even though I have "Primary" specified (I do have spring.main.allow-bean-definition-overriding set to true).

What happens is, during refresh, instead of allowing my bean to override, all you guys do is check if JSR-303 is on the classpath and force your bean.

SpringBoot Cannot override message interpolation with JSR-303

The above stack trace is what is always the last one to set the MessageInterpolator.

Am I missing something or can you guys add proper support for customizing validation?

Affects: Spring Framework 5.2.11

Comment From: fcjreed

Nevermind, I added @RefreshScope and created a bean out of my interpolator instead. Then added @RefreshScope to my LocalValidatorFactoryBean and qualified my MessageInterpolator.

SpringBoot Cannot override message interpolation with JSR-303