I want to create a yaml file from which I get my constants
constantsConfiguration.yml
constants:
myList:
-
id: 11
name: foo1
firstName: bar1
allowed: true
-
id: 22
name: foo2
firstName: bar2
allowed: false
the configuration class looks like this:
@Data
@Component
@PropertySource("classpath:constantsConfiguration.yml")
@ConfigurationProperties(prefix = "constants")
public class ConstantProperties {
private List<User> myList;
@Data
public static class User{
private String id;
private String name;
private String firstName;
private Boolean allowed;
}
}
and this is a dummy example of how I want use it
@Service
@RequiredArgsConstructor
public class MyService{
private final ConstantProperties constantProperties;
public Boolean isEmptyList(){
return CollectionUtils.isEmpty(constantProperties.getMyList());
}
}
constantProperties.getMyList() is always null
I am using spring boot : 2.5.12 and java 11