I have a application.properties:
app.cert.identity.subject.organizationalUnit=test
app.cert.identity.subject.O=Pacific College
app.cert.identity.subject.L=CanTho
app.cert.identity.subject.ST=CanTho
app.cert.identity.subject.C=VN
My class:
@Configuration
@ConfigurationProperties(prefix = "app.cert.identity")
@EnableConfigurationProperties
@Data
public class IdentityCertificateDefinition {
private Subject subject;
@Data
@Configuration
public static class Subject {
private String organizationalUnit; //Does work
@Value("${app.cert.identity.subject.O}") //Does NOT work
private String organization;
@Value("${app.cert.identity.subject.L}") //Does NOT work
private String location;
@Value("${app.cert.identity.subject.ST}") //Does NOT work
private String state;
@Value("${app.cert.identity.subject.C}") //Does NOT work
private String countryCode;
@Value("${app.cert.identity.validity.not-after-in-days}") //Does NOT work
private int notAfterInDays;
}
}
And here is the result: You guys can see just the organizationalUnit work, the rest doesn't work (all are null). I do not know how to make the rest properties work. I would like to keep application.properties.
application.properties
file have some conflicts withSPACE
and_
underscore
So we cannot add them in properties file. So please try to remove itapp.cert.identity.subject.O=Pacific College
move this from second position to last position. You will observe all the properies values are accessable but not the last one