Closed
Description
Sanjay Acharya opened SPR-12297 and commented
Would be very useful if Spring allowed for the injection of javax.inject.Provider along with @Value
annotation for properties that could change at Runtime.
public class Foo {
private final Provider<Integer> changeableIntegerProperty;
public Foo(Provider<Integer> changeableIntegerProperty) {
this.changeableIntegerProperty = changeableIntegerProperty;
}
public void someOperation() {
changeableIntegerProperty.get(); // Gets current value of the property
}
}
@Configuration
public class FooConfig {
@Bean
public Foo foo(@Value("${fooProp}") Provider<Integer> fooProp) {
return new Foo(fooProp);
}
}
If the same code shown above were attempted now, a TypeMismatchException gets thrown in TypeConverterSupport due to the nesting level of the parameter not set to 1.
My request for improvement is to allow the injection of java.inject.Provider along with @Value
.
Thanks.
Affects: 3.2.11, 4.0.7, 4.1.1
Issue Links:
- MapToMapConverter cannot distinguish MultiValueMap in target [SPR-9499] #14133 MapToMapConverter cannot distinguish MultiValueMap in target
- Provide support for javax.inject.Provider<> style injection for @Value and @Autowired [SPR-6079] #10747 Provide support for javax.inject.Provider<> style injection for
@Value
and@Autowired
1 votes, 3 watchers