BeanDefinitionOverrideException although Spring-Property overriding is enabled - java

Although the spring-property allow-bean-definition-overriding: true is enabled in the main application.yml, I am getting an Exception. Any clue why?
Application Start
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'httpSessionManager', defined in class path resource [...], could not be registered. A bean with that name has already been defined in URL [...HttpSessionManager.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Test Start
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'metaDataSourceAdvisor' could not be registered. A bean with that name has already been defined and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

If you look at the error message, it says:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true.
Make sure your allow-bean-definition-overriding property is under the spring.main element.

Related

Code generation issue for AsyncAPI definition using java-spring-template

I'm trying to generate the code using this java-spring-template using this async API definition. After building it, when I try to start using ./gradlew bootRun , it gives the following error.
Can someone point out the issue in the definition please?
***************************
APPLICATION FAILED TO START
***************************
Description:
A component required a bean named 'signedupOutboundChannel' that could not be found.

The bean org.springframework.transaction.config.internalTransactionalEventListenerFactory could not be registered

"The bean org.springframework.transaction.config.internalTransactionalEventListenerFactory could not be registered. A bean with that name has already been defined and overriding is disabled."
After spring upgrade from 4.3.18 to 5.3.21 the above error has appeared.
Setting the spring.main.allow-bean-definition-overriding=true in properties file is not resolving the issue.

Java Spring Boot Circular Dependency on one environment

I have a spring boot application which runs well on my local, UAT, and Prod environments but when I deploy it in a staging environment, it gives the following error:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'Bean 1': Unsatisfied dependency expressed through field 'Class 1'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'Bean2 of type Class1': Bean with the name 'Bean2' has been injected into other beans [Bean 3] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.
I am not sure if it's related to the build process or what. I have checked the code, there are no circular dependencies. When I annotate Bean2 with #Lazy on Class3, it works well. But I am not able to figure out why it works on other environments and this annotation is needed only for the Staging.

Spring boot unexpected duplicate bean

When I run spring boot I get the following error. I have replaced sensitive parts with '...' as the problem should be clear anyway. This error happened without me changing any of the code in the class that is causing the error.
Description:
The bean '...', defined in class path resource [....class], could not
be registered. A bean with that name has already been defined in URL
[jar:file:/C:/m2/repository/.../0-SNAPSHOT/...-0-SNAPSHOT.jar!/...class]
and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting
spring.main.allow-bean-definition-overriding=true

Project looking for a datasource but I am using MongoDB

Description: I am using MongoDB and it keeps asking for a datasource. I have excluded the following:
exclude=DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
HibernateJpaAutoConfiguration.class,
JpaRepositoriesAutoConfiguration.class})
error:
Error starting ApplicationContext. To display the conditions report re-run
your application with 'debug' enabled.
2018-10-29 11:03:25.968 ERROR 4676 --- [ restartedMain]
o.s.b.d.LoggingFailureAnalysisReporter :
Description:
***************************
APPLICATION FAILED TO START
***************************
Parameter 1 of method batchConfigurer in org.springframework.boot.autoconfigure.batch.BatchConfigurerConfiguration$JdbcBatchConfiguration required a bean of type 'javax.sql.DataSource' that could not be found.
- Bean method 'dataSource' not loaded because #ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
- Bean method 'dataSource' not loaded because #ConditionalOnClass did not find required class 'javax.transaction.TransactionManager'
Action:
Consider revisiting the entries above or defining a bean of type 'javax.sql.DataSource' in your configuration.
Spring Boot is intended for building production grade applications. When it is used to build a Spring Batch application, it requires a data source to persist Spring Batch meta-data (See BATCH-2704).
But you can always use either:
an embedded datasource supported by Spring Boot (H2, HSQL or Derby) by just adding it to the classpath. This data source will be picked up automatically by Spring Batch
or provide a custom BatchConfigurer and use the MapJobRepository (See here)
Hope this helps.

Categories