I'm working on Micronaut 4.1.3 and I can't use @PropertySource in getting the value of yaml file aside from application.yml / .properties.
@PropertySource("classpath:new.yaml")
public class TestConfig {
private String first;
}
I encounter the issue:
Incompatible types. Found: 'java.lang.String', required: 'io.micronaut.context.annotation.Property[]'
Is there a workaround on this? TIA
@PropertySourceis meant to define only array of properties not the source file.So you can do, something like
If you need to add the source file, you can do that by defining
environmentson @MicronautTest orpropertySources. Where environments will be loading dedicatedapplication-{env}.ymlfile.