IBM Cloud Service Binding for Spring Boot

Auto configuration for Spring Boot apps bound to IBM Cloud services

License

License

Categories

Categories

Spring Boot Container Microservices IBM Cloud PaaS Providers
GroupId

GroupId

com.ibm.cloud
ArtifactId

ArtifactId

ibm-cloud-spring-boot-service-bind
Last Version

Last Version

1.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

IBM Cloud Service Binding for Spring Boot
Auto configuration for Spring Boot apps bound to IBM Cloud services
Project URL

Project URL

https://github.com/ibm-developer/ibm-cloud-spring-bind
Source Code Management

Source Code Management

http://github.com/ibm-developer/ibm-cloud-spring-bind/tree/master

Download ibm-cloud-spring-boot-service-bind

How to add to project

<!-- https://jarcasting.com/artifacts/com.ibm.cloud/ibm-cloud-spring-boot-service-bind/ -->
<dependency>
    <groupId>com.ibm.cloud</groupId>
    <artifactId>ibm-cloud-spring-boot-service-bind</artifactId>
    <version>1.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.ibm.cloud/ibm-cloud-spring-boot-service-bind/
implementation 'com.ibm.cloud:ibm-cloud-spring-boot-service-bind:1.1.2'
// https://jarcasting.com/artifacts/com.ibm.cloud/ibm-cloud-spring-boot-service-bind/
implementation ("com.ibm.cloud:ibm-cloud-spring-boot-service-bind:1.1.2")
'com.ibm.cloud:ibm-cloud-spring-boot-service-bind:jar:1.1.2'
<dependency org="com.ibm.cloud" name="ibm-cloud-spring-boot-service-bind" rev="1.1.2">
  <artifact name="ibm-cloud-spring-boot-service-bind" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.ibm.cloud', module='ibm-cloud-spring-boot-service-bind', version='1.1.2')
)
libraryDependencies += "com.ibm.cloud" % "ibm-cloud-spring-boot-service-bind" % "1.1.2"
[com.ibm.cloud/ibm-cloud-spring-boot-service-bind "1.1.2"]

Dependencies

compile (6)

Group / Artifact Type Version
org.springframework.boot : spring-boot-autoconfigure jar 1.5.9.RELEASE
org.springframework : spring-core jar 4.3.12.RELEASE
org.springframework : spring-beans jar 4.3.12.RELEASE
org.springframework : spring-context jar 4.3.12.RELEASE
com.jayway.jsonpath : json-path jar 2.2.0
com.fasterxml.jackson.core : jackson-databind jar 2.9.2

test (4)

Group / Artifact Type Version
org.springframework : spring-test jar 4.3.12.RELEASE
org.springframework.boot : spring-boot-starter-test jar 1.5.9.RELEASE
org.mockito : mockito-core jar 1.10.19
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

IBM Cloud Service Bindings For Spring Boot

This library provides Spring Boot auto configuration for accessing IBM Cloud services config data.

Overview

This library allows easy access to IBM Cloud services configuration data for services that have been bound to a Spring Boot application.

Including the dependency ibm-cloud-spring-boot-service-bind auto configures a PropertySource to allow service configuration using Spring property source mechanisms such as @Value annotations, Environment objects, etc.

Multiple runtime environments are supported such as:

  • IBM Cloud - Kubernetes
  • IBM Cloud - Cloud Foundry
  • local / on prem - access to IBM Cloud hosted services

The supported methods of binding a service to your application are:

  • IBM Cloud App Services console
  • IBM Cloud Developer Tools CLI
  • Manual Binding

Usage

Dependency configuration:

Maven:

<dependency>
   <groupId>com.ibm.cloud</groupId>
   <artifactId>ibm-cloud-spring-boot-service-bind</artifactId>
   <version>1.1.2</version>
</dependency>

Gradle:

dependencies {
    compile group: 'com.ibm.cloud', name: 'ibm-cloud-spring-boot-service-bind', version: '1.1.2'
}

To access service configuration in your code you can use the @Value annotation, or use the Spring framework Environment class' getProperty() method.

Example: Accessing configuration data for an IBM Cloudant NoSQL DB service:

     @Autowired
     Environment env; 

     @Value("cloudant.url")
     String cloudantUrl;

     String cloudantUsername = 
          env.getProperty("cloudant.username");

Binding IBM Cloud Services to a Spring Boot Application

Your application must be bound to an IBM Cloud service in order to use this library. The following methods of service binding are supported:

  1. IBM Cloud App Services Console

    You can use the IBM Cloud App Services Console to create Spring Boot apps, create services, and bind the services to apps.

  2. IBM Cloud Developer Tools CLI

    You can also use the IBM Cloud Developer Tools CLI to create a Spring Boot app, create services, and bind the services to the app.

  3. Manually create an IBM Cloud service and add the configuration values to the application.properties file.

    For example, from the IBM Cloud Services Catalg select the Cloudant NoSQL DB service and click Create to create a Cloudant service.

    On the Service Credentials tab of the service select the View Credentials drop down and copy the username, password, and url values to your app's application.properties file as follows:

    cloudant.username=62c520dc-9367...  
    cloudant.password=8c03bd171cd99...
    cloudant.url=https://62c520dc-9367...cloudant.com

Additionally, the generated mappings.json file will be used to define search parameters for discovering credentials for services. See the IBM Cloud Env readme for more information about this file.

Related documentation

Development

Contributing

See CONTRIBUTING.md.

Using in Other Projects

The preferred approach for using ibm-cloud-spring-boot-service-bind in other projects is to use the Gradle or Maven dependency as described above.

License

Copyright © 2018 IBM Corp. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "license"); you may not use this file except in compliance with the license. you may obtain a copy of the license at

http://www.apache.org/licenses/LICENSE-2.0.html

Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "as is" basis, without warranties or conditions of any kind, either express or implied. See the license for the specific language governing permissions and limitations under the license.

Issues

Before opening a new issue please consider the following:

  • Please try to reproduce the issue using the latest version.
  • Please check the existing issues to see if the problem has already been reported. Note that the default search includes only open issues, but it may already have been closed.
com.ibm.cloud

IBM-Developer

Versions

Version
1.1.2
1.1.1
1.1.0
1.0.0