Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How to disable spring data auto configuration in spring boot?


Asked by Phillip Acosta on Dec 12, 2021 Spring



1. Introduction In this quick tutorial, we'll explore two different ways to disable database auto-configuration in Spring Boot, which can come in handy, say, when testing. We'll see examples for Redis, MongoDB, and Spring Data JPA. Firstly, we'll start by looking at the annotation-based approach and then we'll look at the property file approach.
Thereof,
We can also disable the specific auto-configuration classes, if we do not want to be applied. We use the exclude attribute of the annotation @EnableAutoConfiguration to disable the auto-configuration classes. For example: import org.springframework.boot.autoconfigure.*; import org.springframework.boot.autoconfigure.jdbc.*;
In fact, Typically AutoConfiguration classes are annotated with @Configuration to mark it as a Spring configuration class and annotated with @EnableConfigurationProperties to bind the customization properties and one or more Conditional bean registration methods.
Indeed,
Spring Security is in fact behind Spring Boot Security, so any security configuration that can be done with this one or any integration this one supports can also be implemented into Spring Boot. 5. Spring Boot OAuth2 Auto-Configuration (Using Legacy Stack)
Next,
Spring Boot also allows you to disable and enable Solr repository by setting following property either in application.properties or in application.yml file. By default, this property set to true. We have seen in this tutorial about basic of the Spring Data Solr configuration in the Spring Boot application.