There was an error while loading. Please reload this page.
Wiki Home ▸ Tips and Tricks for Java
You can read complex env variables with Spring very easily. For example:
"VCAP_APPLICATION": { "uris": [ "sample.url1.com", "sample.url2.com" ] }
Retrieve the first URI from the uris array. In the application.yml file, type:
app: url: ${vcap.application.uris[0]:default}
Your code-config file should look like this:
@Configuration public class Config { @Value("${app.url}") private String myAppUrl; }
"sample.url1.com" will be inserted into the myAppUrl variable in Config class.
cf set-env app-name JAVA_OPTS "-verbose:gc -XX:+PrintGCDetails"
cf restage app-name
Use the newest version of Java buildpack (support for specifying heap size was added in 3.2):
cf push <APP-NAME> -p <ARTIFACT> -b https://github.com/cloudfoundry/java-buildpack.git
Set environment variables:
cf set-env <APP-NAME> JBP_CONFIG_OPEN_JDK_JRE: [memory_calculator: {memory_sizes: { heap: 64M, metaspace: 34M }}]
Restage application.