Consider defining a bean of type 'org.flywaydb.core.Flyway'

Adnan Yaseen

I have a Spring Boot project in which Flyway is used along with JPA.

<dependency>
  <groupId>org.flywaydb</groupId>
  <artifactId>flyway-core</artifactId>
</dependency>

The project is running absolutely fine. Due to some requirements I had to change the order of Flyway loading so it is loaded after the Hibernate. I searched and found the following solution https://stackoverflow.com/a/44806540/1361888. I created the MigrationConfiguration as suggested as answer in the above link. Now when I run the application then it gives me following error,

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method flywayInitializer in 
com.x2iq.microservice.config.MigrationConfiguration required a bean of type 
'org.flywaydb.core.Flyway' that could not be found.


Action:

Consider defining a bean of type 'org.flywaydb.core.Flyway' in your 
configuration.

Now I fairly new to Spring Boot so unable to understand this error and I could not find anything related to this error online.

andrewdleach

In a @Configuration class you would want to expose a Flyway Bean to the container. Something like this should do the trick:

@Configuration 
public class MigrationConfiguration {

    @Bean
    public Flyway flyway(){
        return new Flyway();
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Consider revisiting the entries above or defining a bean of type 'org.springframework.data.redis.core.RedisTemplate' in your configuration

Consider defining a bean of type 'org.springframework.data.mongodb.core.MongoTemplate' in your configuration

Redis Issue Consider defining a bean of type 'org.springframework.data.redis.core.HashOperations' in your configuration

Consider defining a bean of type 'org.modelmapper.ModelMapper' in your configuration

Consider defining a bean of type * in your configuration

Consider defining a bean of type in your configuration

Consider defining a bean of type 'UserConverter' in your configuration

Consider defining bean of type authentication manager

Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration

Consider defining a bean of type 'org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder' in your configuration

Upgrading Flyway 4.1.2 to 6.4.4 results in NoSuchMethodError: org.flywaydb.core.Flyway.getLocations()

How to fix "Consider defining a bean of type 'org.jooq.DSLContext' in your configuration." after update to jOOQ 3.15.0

upgrade flyway in spring from 5.2.3 to 6.X - org.flywaydb.core.api.callback.FlywayCallback not present

Type org.flywaydb.core.api.callback.FlywayCallback not present

Consider defining a bean of type 'package' in your configuration [Spring-Boot]

Consider defining a bean of type 'service' in your configuration [Spring boot]

Consider defining a bean of type 'javax.servlet.ServletContext' in your configuration

APPLICATION FAILED TO START - Consider defining a bean of type in your configuration [SpringBoot]

Consider defining a bean of type 'int' in your configuration[SpringBoot]

Field in required a bean of type that could not be found consider defining a bean of type in your configuration

Spring Boot @Mapper Bean creation issue : Application Failed to start. Error : Consider defining a bean of Type

Consider defining a bean of type 'io.ipl.amaresh.data.JobCompletionNotificationListener' in your configuration. The bean could not be found in that

Spring Boot - Injecting Repository into Controller throws Consider defining a bean of type 'Type' in your configuration

SpringBootTest - Consider defining a bean of type 'java.lang.String' in your configuration

Consider defining a bean of type '[3rd party dependency]' in your configuration

Consider defining a bean of type 'com.ensat.services.ProductService' in your configuration

only after refactoring packages names, Consider defining a bean of type * in your configuration

Consider defining a bean of type 'com.gisapp.gisapp.dao.IUserDAO' in your configuration

How do i resolve Consider defining a bean of type 'java.lang.String' in your configuration?