Using custom @Enable* annotations to toggle configurations

Allowing Spring Boot to automatically evaluate the classpath and detected configurations that are found there makes it very quick and easy to get a simple application going. However, there are times when we want to provide the configuration classes but require consumers of the starter library to explicitly enable such a configuration rather than relying on Spring Boot to decide automatically if it should be included or not.

We will modify our previous recipe to enable the starter via a meta-annotation rather than using the spring.factories route.

How to do it…

  1. First, we will comment out the content of the spring.factories file located in db-count-starter/src/main/resources in the root of ...

Get Spring Boot Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.