Spring Boot Starter since 2.3.0

Getting Started

Add the Togglz Spring Boot Starter dependency to your project:


Or when using Gradle simply:


The starter will not only add the togglz-core and togglz-spring-core modules to your project, it will also enable the auto configuration of the Togglz configration.

Optionally add the togglz-console, togglz-spring-security, togglz-junit and thymeleaf-extras-togglz modules:

<!-- Togglz Admin Console (optional) -->

<!-- Togglz Spring Security (optional) -->

<!-- Togglz JUnit Testing Support (optional) -->

<!-- Thymeleaf Togglz Dialect (optional) -->

Or when using Gradle:


Auto Configuration

The togglz-spring-boot-starter will automatically trigger the Togglz Spring Boot auto configuration. It will create all necessary beans and in particular the Togglz FeatureManager. The only thing that needs to provided is a FeaturesProvider e.g.:

public enum MyFeatures implements Feature {

    @Label("First Feature")

    @Label("Second Feature")

    public boolean isActive() {
        return FeatureContext.getFeatureManager().isActive(this);

public FeatureProvider featureProvider() {
    return new EnumBasedFeatureProvider(MyFeatures.class);

Alternatively the togglz.feature-enums application property can be provided so even the FeatureProvider is not needed.

By default the auto configuration will use a NoOpUserProvider and when Spring Security is used a SpringSecurityUserProvider.

If the togglz-console module is added then the TogglzConsoleServlet is registered using a ServletRegistrationBean.

Also any beans of type ActivationStrategy found in the application content will be added to the FeatureManager automatically.

If you define a UserProvider, StateRepository, ActivationStrategyProvider or even a FeatureManager manually the auto configuration will not create these beans and will use the ones already available in the application context.

The auto configuration also supports providing feature values inside your application.properties/application.yml. See an example below of the application.yml. Note this is a Spring Boot in-memory implementation of a StateRepository which does not persist edited features. If persistence is needed a FileBasedStateRepository, JDBCStateRepository or any other applicable StateRepository must be added to the application context manually. When you want to use a FileBasedStateRepository you can also use this by providing a togglz.features-file application property. If the togglz.features-file is provided this will take precedence over features provided via application properties and effectively ignoring togglz.features. The togglz.features-file property is processed by getResource() so in most cases you should provide a file url for this property. To get a file in the local working directory you may use something like togglz.features-file = file:./togglz.properties.

Admin Console Security

By default the Togglz admin console is secured using the UserProvider bean. Which UserProvider bean the auto configuration configures depends on the availability of the Spring Security dependency. If Spring Security is on the classpath a SpringSecurityUserProvider is configured. In this case it will check if the user has the authority as provided by the togglz.console.feature-admin-authority application property. If Spring Security is not on the classpath a NoOpUserProvider is configured which provides a null user to the admin console servlet. This also means the admin console will not be accessible. For quick testing the togglz.console.secured application property can be set to false. This will bypass security completely for the admin console. Be careful in production with this setting as it will give everybody access to the admin console. Setting togglz.console.secured to false is also useful when you want to protect the admin console independently from the UserProvider.

Application Properties

The following properties can be specified inside your application.properties/application.yml file or as command line switches:

  enabled: true # Enable Togglz for the application.
  feature-enums: # Comma-separated list of fully-qualified feature enum class names.
  feature-manager-name: # The name of the feature manager.
  features: # The feature states. Only needed if feature states are stored in application properties.
    HELLO_WORLD: true
    REVERSE_GREETING.strategy: username
    REVERSE_GREETING.param.users: user2, user3
  features-file: # The path to the features file that contains the feature states. Only needed if feature states are stored in external properties file.
  features-file-min-check-interval: # The minimum amount of time in milliseconds to wait between checks of the file's modification date.
    enabled: false # Enable feature state caching.
    time-to-live: 0 # The time after which a cache entry will expire.
    time-unit: milliseconds # The time unit as java.util.concurrent.TimeUnit enum name (one of "nanoseconds", "microseconds", "milliseconds", "seconds", "minutes", "hours", "days").
    enabled: true # Enable admin console.
    path: /togglz-console # The path of the admin console when enabled.
    feature-admin-authority: ROLE_ADMIN # The name of the authority that is allowed to access the admin console.
    secured: true # Indicates if the admin console runs in secured mode. If false the application itself should take care of securing the admin console.
    id: togglz # The endpoint identifier.
    enabled: true # Enable actuator endpoint.
    sensitive: true # Indicates if the endpoint exposes sensitive information.