This repository will not be updated. The repository will be kept available in read-only mode.
This library provides Spring Boot auto configuration for accessing IBM Cloud services config data.
- Overview
- Usage
- Binding IBM Cloud Services to a Spring Boot Application
- Related Documentation
- Development
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
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");
Your application must be bound to an IBM Cloud service in order to use this library. The following methods of service binding are supported:
-
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.
-
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.
-
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
, andurl
values to your app'sapplication.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.
- IBM Cloud Env
- IBM Cloud Developer Tools CLI
- IBM Cloud App Services Console
- IBM Cloud Services Catalg
- Spring Boot documentation
See CONTRIBUTING.md.
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.
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.
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.