org.springframework.config.java.annotation
Annotation Type ExternalValue


@Retention(value=RUNTIME)
@Target(value={METHOD,FIELD})
@Inherited
@Documented
public @interface ExternalValue

Annotation used to assign externally-supplied values to fields and/or methods. If a field has a default value, that default value will be used if no property can be found. If an ExternalValue-annotated method is non-abstract, its method body will be executed if no matching external value can be found.

use on fields

 @Configuration
 @PropertiesValueSource(locations="some.properties")
 public class Config {
     @ExternalValue("value.1") String value1;
     @ExternalValue("value.2") String value2;

     public @Bean Foo foo() {
         return new Foo(value1, value2);
     }
 }
 

use on methods

 @Configuration
 @PropertiesValueSource(locations="some.properties")
 public abstract class Config {
     abstract @ExternalValue("value.1") String value1();
     abstract @ExternalValue("value.2") String value2();

     public @Bean Foo foo() {
         return new Foo(value1(), value2());
     }
 }
 

Author:
Chris Beams, Rod Johnson
See Also:
ValueResolver, PropertiesValueSource, EnvironmentValueSource

Optional Element Summary
 java.lang.String value
          Indicates the property name to be looked up against any registered ValueResolver beans.
 

value

public abstract java.lang.String value
Indicates the property name to be looked up against any registered ValueResolver beans. If left empty, value will default to the name of the annotated field or method.

Default:
""