When you do cf env on your app, you see an environment variable named VCAP_SERVICES that contains a JSON data structure like you showed:
VCAP_SERVICES: {
"user-provided": [
{
"credentials":{ "db":"text" },
"name":"myservice"
}
]
}
Your application can retrieve this JSON structure with System.getenv("VCAP_SERVICES"). You can then parse the JSON returned from that call into a Map, for example, and retrieve the values needed.
There is no environment variable available to your app named cloud.services.myservice.db, so System.getenv("cloud.services.myservice.db") won't return anything useful.
Spring Boot parses the VCAP_SERVICES environment variable and creates Spring environment properties like cloud.services.myservice.credentials.db and vcap.services.myservice.credentials.db. These properties can't be retrieved with System.getenv() because they exist only in the Spring environment abstraction, not in the OS environment. This is described nicely in a Spring blog post. More details are in the Spring Boot javadoc.