My spring boot application is in PCF, since PCF doesnt have option to change properties file in run time, I was trying to put the values in PCF VCAP_SERVICES- user-provided credentials.
I tried using @ConfigurationProperties as per tutorial provided by pivotal and i got null exception.
@Data
@Configuration
@ConfigurationProperties("vcap.services.app-properties.credentials")
public class RsTest {
private String username;
private String password;
//getter and setter
};
and my controller looks like
@RestController
public class RestApiController {
@Autowired
RsTest rsTest;
public void test() {
logger.info("RSTest: "+rsTest.getUsername());
return ResponseEntity.ok().body("some value");
}
I'm expecting the credential in RsTest object. But having error Servlet.service() for servlet [dispatcherServlet] in context with path [/myservice] threw exception 2019-08-20T17:32:43.728-04:00 [APP/PROC/WEB/0] [OUT] java.lang.NullPointerException: null