After upgrading spring to version 3.2.1 from 2.7.x and upgrading Flyway to version 10.4.1 from 8.5, I received an exception as in the title:

Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception with message: Name must not be null

I'm using postgresql version 15.x

I managed to solve the problem as follows:

I add or change application propertis:

#spring-flyway settings:
spring.flyway.enabled=true
spring.flyway.baselineOnMigrate=true
spring.flyway.validateOnMigrate=true
spring.flyway.locations=classpath:db/migration

#spring.datasource settings:
spring.datasource.jdbc-url=jdbc:postgresql://localhost:5432/database-name
spring.datasource.url=jdbc:postgresql://localhost:5432/database-name
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.username=<<username>>
spring.datasource.password=<<password>>
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
  1. note the dialect I changed from PostgreSQL10Dialect to PostgreSQLDialect 2a. note the spring.datasource.jdbc-url instead spring.datasource.url= 2b. and jdbc:postgresql instead postgre

I had to add new dependencies: required to support the appropriate databases can be found in the repository or here: In my case https://documentation.red-gate.com/flyway/flyway-cli-and-api/supported-databases

        <!--flyway-->
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
            <version>10.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-sqlserver</artifactId>
            <version>10.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-database-postgresql</artifactId>
            <version>10.4.1</version>
            <scope>runtime</scope>
        </dependency>

previously it was only required flyway-core

1

There are 1 best solutions below

0
Dt D On

I add or change application propertis:

#spring-flyway settings:
spring.flyway.enabled=true
spring.flyway.baselineOnMigrate=true
spring.flyway.validateOnMigrate=true
spring.flyway.locations=classpath:db/migration

#spring.datasource settings:
spring.datasource.jdbc-url=jdbc:postgresql://localhost:5432/database-name
spring.datasource.url=jdbc:postgresql://localhost:5432/database-name
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.username=<<username>>
spring.datasource.password=<<password>>
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect

note the dialect I changed from PostgreSQL10Dialect to PostgreSQLDialect

2a. note the spring.datasource.jdbc-url instead spring.datasource.url=

2b. and jdbc:postgresql instead postgre

I had to add new dependencies: required to support the appropriate databases can be found in the repository or here: In my case https://documentation.red-gate.com/flyway/flyway-cli-and-api/supported-databases

<!--flyway--> <dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-core</artifactId>
    <version>10.4.1</version> </dependency> <dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-sqlserver</artifactId>
    <version>10.4.1</version> </dependency> <dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-database-postgresql</artifactId>
    <version>10.4.1</version>
    <scope>runtime</scope> </dependency>

previously it was only required flyway-core