You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The behavior of configuration and value binding is still not completly consistent. The use of a custom Converter registered as bean or inside a conversionService bean only works in the following cases:
The configuration value will be bound to a configuration bean annotated with @ConfigurationProperties
The configuration value will be injected to bean via @Value annotation if the bean is created after complete refresh of the ApplicationContext.
It does not work, if the configuration value if injected into a bean with @Value if the bean is created during "refresh phase" of the ApplicationContext. This applies for example to all beans created during the initialization of the Tomcat server in a ServletWebServerApplicationContext
I provided a test project which contains multiple test cases showcasing the inconsistent behavior:
Test scenario 1: HealthIndicator bean created during refresh with configuration object => SUCCESS
Test scenario 2: HealthIndicator bean created during refresh with constructor injection via @Value => FAIL
Test scenario 3: @Service bean created after refresh with constructor injection via @Value => SUCCESS
Please also note that the failure of scenario 2 can only be detected in an integration test if a "real" webEnvironment, e.g. RANDOM_PORT, is used. In a mocked web environment, i.e. without actually starting a Tomcat, the problem will not occur.