I have a Spring Boot project with two YAML files in resources
folder:
application.yml
metrics.yml
metrics.yml
looks like this:
metrics:
activeMetrics:
- type: TYPE_A
value: 10
- type: TYPE_B
value: 5
The class for it looks like this:
@Data
@Component
@ConfigurationProperties("metrics")
public class ActiveMetrics {
private final List<Metric> activeMetrics = new ArrayList<>();
}
Main class is annotated with:
@PropertySources({
@PropertySource("classpath:/metrics.yml"),
@PropertySource("classpath:/project.yml")
})
After application startup the activeMetrics
list is empty, however, if I place the same config inside of application.yml
the list initializes successfully.
metrics.yml
is also loaded successfully, because when the path isn't right Spring Boot throws an exception.
How do I initialize this bean with second YAML file?