Annotation Type YamlPropertySource
-
@Target(TYPE) @Retention(RUNTIME) @Inherited @Documented @ResourcePropertySource(factory=YamlPropertySourceFactory.class) public @interface YamlPropertySource
The extension annotation of@ResourcePropertySourceproviding a convenient and declarative mechanism for adding a YAMLImmutableMapPropertySourceto Spring's Environment. To be used in conjunction with@Configurationclasses.Example Usage
Example 1: Basic usage
{@code- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
ResourcePropertySource,ImmutableMapPropertySource,YamlPropertySourceFactory
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.StringafterThe relative order after specifiedPropertySourcebooleanautoRefreshedIt indicates the property source is auto-refreshed when the configuration is changed.java.lang.StringbeforeThe relative order before specifiedPropertySourcejava.lang.StringencodingA specific character encoding for the given resources.booleanfirstbooleanignoreResourceNotFoundIndicate if a failure to find aproperty resourceshould be ignored.java.lang.StringnameIndicate the name of this property source.java.lang.Class<? extends java.util.Comparator<org.springframework.core.io.Resource>>resourceComparatorIndicate the resources to be sorted whenvalue()specifies the resource location wildcardsjava.lang.String[]valueIndicate the resource location(s) of the YAML file to be loaded.
-
-
-
Element Detail
-
name
@AliasFor(annotation=ResourcePropertySource.class) java.lang.String name
Indicate the name of this property source.- See Also:
PropertySource.getName(),Resource.getDescription()
- Default:
- ""
-
-
-
autoRefreshed
@AliasFor(annotation=ResourcePropertySource.class) boolean autoRefreshed
It indicates the property source is auto-refreshed when the configuration is changed.- Returns:
- default value is
false
- Default:
- false
-
-
-
first
@AliasFor(annotation=ResourcePropertySource.class) boolean first
Indicates currentPropertySourceis first order or not If specified ,before()andafter()will be ignored, or last order.- Returns:
- default value is
false
- Default:
- false
-
-
-
before
@AliasFor(annotation=ResourcePropertySource.class) java.lang.String before
The relative order before specifiedPropertySourceIf not specified , current
PropertySourcewill be added last.If
first()specified , current attribute will be ignored.- Returns:
- the name of
PropertySource, default value is the empty string
- Default:
- ""
-
-
-
after
@AliasFor(annotation=ResourcePropertySource.class) java.lang.String after
The relative order after specifiedPropertySourceIf not specified , current
PropertySourcewill be added last.If
first()specified , current attribute will be ignored.- Returns:
- the name of
PropertySource, default value is the empty string
- Default:
- ""
-
-
-
value
@AliasFor(annotation=ResourcePropertySource.class) java.lang.String[] value
Indicate the resource location(s) of the YAML file to be loaded.For example,
"classpath:/com/myco/app.yaml"or"classpath:/com/myco/app.yml"or"file:/path/to/file.yaml".Resource location wildcards (e.g. **/*.yaml) also are permitted;
${...} placeholders will be resolved against any/all property sources already registered with the
Environment.Each location will be added to the enclosing
Environmentas its own property source, and in the order declared.- Default:
- {}
-
-
-
resourceComparator
@AliasFor(annotation=ResourcePropertySource.class) java.lang.Class<? extends java.util.Comparator<org.springframework.core.io.Resource>> resourceComparator
Indicate the resources to be sorted whenvalue()specifies the resource location wildcardsFor example,
"classpath:/com/myco/*.yaml", suppose there are two resources named "a.yaml" and "b.yaml" where two instances ofResourcewill be resolved, they are the sources ofPropertySource, thus it has to sort them to indicate the order ofPropertySourcethat will be added to the enclosingEnvironment.Default is
DefaultResourceComparator- See Also:
DefaultResourceComparator
- Default:
- io.microsphere.spring.config.env.support.DefaultResourceComparator.class
-
-
-
ignoreResourceNotFound
@AliasFor(annotation=ResourcePropertySource.class) boolean ignoreResourceNotFound
Indicate if a failure to find aproperty resourceshould be ignored.trueis appropriate if the YAML file is completely optional.Default is
false.- Default:
- false
-
-
-
encoding
@AliasFor(annotation=ResourcePropertySource.class) java.lang.String encoding
A specific character encoding for the given resources.Default is "UTF-8"
- Default:
- "UTF-8"
-
-