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:
Backported to: 4.0.8, 3.2.12
1 votes, 3 watchers
Sanjay Acharya opened SPR-12297 and commented
Would be very useful if Spring allowed for the injection of javax.inject.Provider along with
@Valueannotation for properties that could change at Runtime.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:
@Valueand@AutowiredBackported to: 4.0.8, 3.2.12
1 votes, 3 watchers