How to fix org.springframework BeanDefinitionOverrideException

PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
JAVAEXCEPTIONSCOLLECTIONSSWINGJDBC
EXCEPTIONS
COLLECTIONS
SWING
JDBC
JAVA 8
SPRING
SPRING BOOT
HIBERNATE
PYTHON
PHP
JQUERY
PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
Here we will see how to fix BeanDefinitionOverrideException.
You may get the BeanDefinitionOverrideException exception while running the test cases, when you update the spring boot version from 2.1.x to 2.2.x.
Here are the sample error logs while building the application.
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:123)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:43)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:244)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
Add the below property in your test application.properties file.
spring.main.allow-bean-definition-overriding=true
That’s it, rebuild the application.
Spring Boot BeanDefinitionOverrideException
Happy Learning 🙂

How To Change Spring Boot Context Path
How to change Spring Boot Tomcat Port Number
Spring Boot MockMvc JUnit Test Example
Spring Boot Lazy Loading Beans Example
Spring Boot Environment Properties reading based on activeprofile
Simple Spring Boot Example
MicroServices Spring Boot Eureka Server Example
How to Get All Spring Beans Details Loaded in ICO
How to use Spring Boot Random Port
How to set Spring Boot SetTimeZone
Spring Boot Apache ActiveMq In Memory Example
Spring Boot JPA Integration Example
How to Configure Spring Profile in Tomcat ?
Spring Boot How to change the Tomcat to Jetty Server
How to set Spring Boot Tomcat session timeout

How To Change Spring Boot Context Path
How to change Spring Boot Tomcat Port Number
Spring Boot MockMvc JUnit Test Example
Spring Boot Lazy Loading Beans Example
Spring Boot Environment Properties reading based on activeprofile
Simple Spring Boot Example
MicroServices Spring Boot Eureka Server Example
How to Get All Spring Beans Details Loaded in ICO
How to use Spring Boot Random Port
How to set Spring Boot SetTimeZone
Spring Boot Apache ActiveMq In Memory Example
Spring Boot JPA Integration Example
How to Configure Spring Profile in Tomcat ?
Spring Boot How to change the Tomcat to Jetty Server
How to set Spring Boot Tomcat session timeout
 


Δ
 Spring Boot – Hello World
 Spring Boot – MVC Example
 Spring Boot- Change Context Path
 Spring Boot – Change Tomcat Port Number
 Spring Boot – Change Tomcat to Jetty Server
 Spring Boot – Tomcat session timeout
 Spring Boot – Enable Random Port
 Spring Boot – Properties File
 Spring Boot – Beans Lazy Loading
 Spring Boot – Set Favicon image
 Spring Boot – Set Custom Banner
 Spring Boot – Set Application TimeZone
 Spring Boot – Send Mail
 Spring Boot – FileUpload Ajax
 Spring Boot – Actuator
 Spring Boot – Actuator Database Health Check
 Spring Boot – Swagger
 Spring Boot – Enable CORS
 Spring Boot – External Apache ActiveMQ Setup
 Spring Boot – Inmemory Apache ActiveMq
 Spring Boot – Scheduler Job
 Spring Boot – Exception Handling
 Spring Boot – Hibernate CRUD
 Spring Boot – JPA Integration CRUD
 Spring Boot – JPA DataRest CRUD
 Spring Boot – JdbcTemplate CRUD
 Spring Boot – Multiple Data Sources Config
 Spring Boot – JNDI Configuration
 Spring Boot – H2 Database CRUD
 Spring Boot – MongoDB CRUD
 Spring Boot – Redis Data CRUD
 Spring Boot – MVC Login Form Validation
 Spring Boot – Custom Error Pages
 Spring Boot – iText PDF
 Spring Boot – Enable SSL (HTTPs)
 Spring Boot – Basic Authentication
 Spring Boot – In Memory Basic Authentication
 Spring Boot – Security MySQL Database Integration
 Spring Boot – Redis Cache – Redis Server
 Spring Boot – Hazelcast Cache
 Spring Boot – EhCache
 Spring Boot – Kafka Producer
 Spring Boot – Kafka Consumer
 Spring Boot – Kafka JSON Message to Kafka Topic
 Spring Boot – RabbitMQ Publisher
 Spring Boot – RabbitMQ Consumer
 Spring Boot – SOAP Consumer
 Spring Boot – Soap WebServices
 Spring Boot – Batch Csv to Database
 Spring Boot – Eureka Server
 Spring Boot – MockMvc JUnit
 Spring Boot – Docker Deployment