I have the following configuration class for setting custom application.properties
properties
@Component
@EnableConfigurationProperties
@ConfigurationProperties("app.properties.parseaddress")
public class ParseAddressProperties {
private String endpoint;
public String getEndpoint() {
return endpoint;
}
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
}
In my application.properties I have
app.properties.parseaddress.endpoint=http://myurl.com:5000/parseAddress
I try to use the property in the following class
@Component
public class AddressParser {
@Autowired
ParseAddressProperties parseAddressProperties;
public void parseAddress(String address) throws UnsupportedEncodingException, IOException {
JavaHttpClient httpClient = new JavaHttpClient();
System.out.println(parseAddressProperties.getEndpoint());
httpClient.postRequest(parseAddressProperties.getEndpoint(), "address", address);
}
}
However parseAddressProperties.getEndpoint()
returns null
Any idea what I am doing wrong?