Description
Jose Antonio Iñigo opened SPR-13603 and commented
It would be nice to be able to use @Value
as meta annotation:
Having a properties file and the necessary context:properties-placeholder configuration...
someproperty=somevalue
In a Spring bean we could have:
@Value("${someproperty}")
private String someProperty;
Where someProperty's value would be "somevalue".
I want to create a new annotation @Refreshable
with @Value
as meta-annotation so that it behaves the same as using @Value
directly. Since @Value
requires a value I hardcode "default" hoping that @Refreshable
's value() will override it:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Value("default")
public @interface Refreshable {
String value();
}
Then when I use the new annotation in a bean, I was expecting it to work properly, injecting the declared value "somevalue", but it doesn't, I get "default".
@Refreshable("${someproperty}")
private String someProperty;
Reference URL: http://stackoverflow.com/questions/32964391/annotation-with-spring-value-meta-annotation-not-injecting-the-value
Issue Links:
- @AliasFor attribute name should default to declaring attribute [SPR-13828] #18401
@AliasFor
attribute name should default to declaring attribute - Support @AliasFor for @JmsListener attributes [SPR-13803] #18376 Support
@AliasFor
for@JmsListener
attributes
Referenced from: commits 4f95593