Pivotal + VMware: Transforming how more of the world builds software

Using a Cloud Database connection.

1. Include the maven dependency

<dependency>
   <groupId>org.springframework.boot</group>
   <artifactId>spring-boot-starter-cloud-connectors</artifactId>
</dependency>

2. Create a Cloud Configuration class

@Configuration
@Profile("cloud")
public class CloudConfig extends AbstractCloudConfig {

    @Bean
    public DataSource dataSource() {
        return connectionFactory().dataSource();
    }

}

3. Optionally, create an application-cloud.properties file

This file should contain information about the DB used in the cloud if different than test/standalone. For example:

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialects
spring.datasource.platform=mysql
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
Contact Us