So I'm new to Spring and I'm basically trying to make a REST service for the first time. Some of the data I'd like to return is some data from a properties file.
This is my configuration bean:
@Configuration
@PropertySource("classpath:client.properties")
public class PropertyConfig {
@Bean
public static PropertySourcesPlaceholderConfigurer
propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
This is the class containing the info I want to return from the API. When I hover over the values, I can see that the property is being injected.
public class ProviderInfo {
@Value("${op.iss}") private String issuer;
@Value("${op.jwks_uri}") private String jwksURI;
@Value("${op.authz_uri}") private String authzURI;
@Value("${op.token_uri}") private String tokenURI;
@Value("${op.userinfo_uri}") private String userInfoURI;
// Getter methods
}
And this is the RestController
@RestController
public class ProviderInfoController {
@RequestMapping(value = "/provider-info", method = RequestMethod.GET)
public ProviderInfo providerInfo() {
return new ProviderInfo();
}
}
When I navigate to that endpoint, everything is null:
{"issuer":null,"jwksURI":null,"authzURI":null,"tokenURI":null,"userInfoURI":null}
Can anybody see what I'm doing wrong? Or if there is a better way to accomplish this in general?
Thanks!