2. Getting Started

To get started, create a Spring Boot application and include the Spring Cloud App Broker dependency in the application’s build file.spring-doc.cn

2.1. Maven Dependencies

If you use Maven, include the following in your application’s pom.xml file:spring-doc.cn

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-app-broker-cloudfoundry</artifactId>
        <version>2.2.0-SNAPSHOT</version>
    </dependency>
</dependencies>

2.2. Gradle Dependencies

If you use Gradle, include the following in your application’s build.gradle file:spring-doc.cn

dependencies {
    api 'org.springframework.cloud:spring-cloud-starter-app-broker-cloudfoundry:2.2.0-SNAPSHOT'
}

2.3. Configuring the Service Broker

The service broker is configured with Spring Boot externalized configuration, supplied by a YAML or Java Properties file (for example, you can provide configuration in the application.yml file). Because Spring Cloud App Broker builds on Spring Cloud Open Service Broker, you must provide Spring Cloud Open Service Broker configuration to use Spring Cloud App Broker.spring-doc.cn

To do so, include Spring Cloud Open Servce Broker configuration using properties under spring.cloud.openservicebroker as follows:spring-doc.cn

spring:
  cloud:
    openservicebroker:
      catalog:
        services:
        - name: example
          id: ebca66fd-461d-415b-bba3-5e379d671c88
          description: A useful service
          bindable: true
          tags:
          - example
          plans:
          - name: standard
            id: e19e6bc3-37c1-4478-b70f-c7157ebbb28c
            description: A standard plan
            free: true

Then include Spring Cloud App Broker configuration using properties under spring.cloud.appbroker, as follows:spring-doc.cn

spring:
  cloud:
    appbroker:
      services:
        - service-name: example
          plan-name: standard
          apps:
            - name: example-service-app1
              path: classpath:app1.jar
            - name: example-service-app2
              path: classpath:app2.jar
      deployer:
        cloudfoundry:
          api-host: api.sys.example.local
          api-port: 443
          username: admin
          password: adminpass
          default-org: test
          default-space: development