Use this example application to integrate with the CloudBees platform and test feature management. After integrating, observe changes in the application UI as you update flag values in the CloudBees platform.
In this example, the Rox SDK is already set up, and feature flags are implemented in the code.
To get started with the springboot-fm-example project, follow these steps:
-
Using Git, clone the https://github.com/cloudbees-io/springboot-fm-example repository to your local machine:
git clone git@github.com:cloudbees-io/springboot-fm-example.git
-
In your IDE, select File and open the cloned repository as a Gradle project. You will revisit this project in your IDE later to run the application.
-
Locate and copy the SDK key:
- Navigate to Feature management > Flags.
- Select an application.
- Select [COPY] next to the SDK key on the page.
Note:
If no SDK key is available:
- Navigate to Feature management > Flags.
- Select Install instructions in the upper-right corner.
- Follow the installation steps. The SDK key appears once an application is linked to an environment.
- Close the installation instructions and copy the SDK key.
-
Add the SDK key to the application:
-
Open the
application.yamlfile:src/main/resources/application.yaml
-
Locate the following placeholder in the file, and replace it with your SDK key:
key: "<Your CloudBees SDK key>"
-
-
Save the updated file.
-
Run the application in your IDE. For example:
./gradlew bootRun
-
To view the application running, go to
http://localhost:8080/api/demoin your web browser.
Now that your application is running:
- In the CloudBees platform, select Feature management.
- Select your example application to display the available flags as shown in the table below.
| Flag name | Flag type | Description |
|---|---|---|
showMessage |
Boolean | Turns the message on or off. |
message |
String | Sets the message text. |
fontSize |
Number | Sets the message font size in pixels. Values: 12, 16, or 24. |
fontColor |
String | Sets the message font color. Values: red, green, or blue. |
Note:
If no flags are displayed, verify that the environment-specific SDK key is correctly added to:src/main/resources/application.yaml
Save the file, and restart the application.
To update flags in the platform UI:
- Select Feature management from the left pane.
- Select the application.
- Select the vertical ellipsis next to the flag you want to configure.
- Select Configure.
- Select the Environment for the SDK key.
- Update a flag value and save your changes.
- Set the Configuration status to On.
Run multiple instances of the SDK in a single application, each with its own SDK key and environment. Each instance is fully isolated. Use this when you need to read or compare flags across environments without redeploying, support multi-tenant routing, or combine server-side and client-side evaluations in one application.
To use multiple SDK keys in the example Spring Boot application, follow these steps:
- Retrieve the SDK keys for the environments you’ll use.
- Initialize a separate SDK instance for each key.
- Decide how to route requests to instances (for example, by tenant, region, or environment selector).
- Perform register/fetch/stream setup on each instance as required by your SDK.
- Evaluate flags using the selected instance. Pass a consistent user/context object for accurate targeting.
- Tag logs or metrics by instance, and shut down instances you no longer need.
-
For more information about using multiple SDK keys, refer to https://docs.cloudbees.com/docs/cloudbees-platform/latest/feature-management/use-multiple-sdk-keys.
-
For installation details, refer to https://docs.cloudbees.com/docs/cloudbees-platform/latest/install-sdk/.