Skip to content

Split-Community/spring-boot-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Feature Flag Managed Spring Boot Application

A streamlined Spring Boot application with Split.io feature flag integration.

Project Structure

The application has a simplified architecture:

  • controller: Contains the REST controller that handles HTTP requests
  • service: Contains the service interface and feature flag implementation
  • Main application class that bootstraps the Spring Boot application and configures the Split.io client

Getting Started

Prerequisites

  • Java 17 or higher
  • Maven 3.6 or higher
  • Split.io API key
  • feature flag called 'feature_a' in your environment

Configuration

The application uses an environment variable for the Split.io API key:

SPLIT_API_KEY=your-actual-split-api-key

You can set this in your environment or use the provided run script.

Running the application

Using the run script:

chmod +x run_command
./run_command

Manually with Maven:

export SPLIT_API_KEY=your-actual-split-api-key
mvn spring-boot:run

The application will start on port 8080.

Testing the API

Once the application is running, you can test the API by visiting:

http://localhost:8080/api/message

This endpoint returns the treatment value from the Split.io feature flag "feature_a" (typically "on" or "off").

Feature Flag Implementation

The application uses Split.io for feature flagging:

  • The Split.io Java client is initialized in the main application class
  • Feature flags are configured via the Split.io dashboard
  • The API endpoint returns the raw treatment value from the "feature_a" flag
  • User key is currently hardcoded as "user-key-123" for demonstration

Customizing

To customize the feature flag behavior:

  1. Modify FeatureFlagMessageService to use different flag names or additional conditions
  2. Add more sophisticated user targeting by replacing the hardcoded user key
  3. Add conditional logic based on treatment values to control application behavior

About

Split Java SDK Spring Boot Example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages