2
respostas

Erro ao tentar usar o FLYWAY

Estou fazendo o curso de spring boot , e não consigo utilizar o FLYWAY. Ja tentei mudar de todas as formas meu pom.xml porem ainda continua um erro

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2023-11-10T09:59:47.169-03:00 ERROR 10600 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.configureProperties(FlywayAutoConfiguration.java:185)

The following method did not exist:

'org.flywaydb.core.api.configuration.FluentConfiguration org.flywaydb.core.api.configuration.FluentConfiguration.placeholderSeparator(java.lang.String)'

The calling method's class, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration, was loaded from the following location: jar:file:/C:/Users/Pichau/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/3.0.0-M5/spring-boot-autoconfigure-3.0.0-M5.jar!/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class The called method's class, org.flywaydb.core.api.configuration.FluentConfiguration, is available from the following locations: jar:file:/C:/Users/Pichau/.m2/repository/org/flywaydb/flyway-core/7.15.0/flyway-core-7.15.0.jar!/org/flywaydb/core/api/configuration/FluentConfiguration.class The called method's class hierarchy was loaded from the following locations: org.flywaydb.core.api.configuration.FluentConfiguration: file:/C:/Users/Pichau/.m2/repository/org/flywaydb/flyway-core/7.15.0/flyway-core-7.15.0.ja Action: Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration and org.flywaydb.core.api.configuration.FluentConfiguration

meu Pom.XML 4.0.0 org.springframework.boot spring-boot-starter-parent 3.0.0-M5 med.voll api 0.0.1-SNAPSHOT api API Rest da aplicação Voll.med <java.version>17</java.version> org.springframework.boot spring-boot-starter-data-jpa 3.1.5 org.springframework.boot spring-boot-starter-validation 3.1.5 org.springframework.boot spring-boot-starter-web 3.1.5 org.flywaydb flyway-core 7.15.0 org.flywaydb flyway-mysql 10.0.0

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.33</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>3.1.5</version>
        <scope>test</scope>
    </dependency>
</dependencies>
2 respostas

Parece que a versão do Spring Boot que você está usando (3.0.0-M5) é incompatível com a versão do Flyway (7.15.0) que você está utilizando. A mensagem de erro destaca que o método placeholderSeparator em org.flywaydb.core.api.configuration.FluentConfiguration não está disponível na versão do Flyway que o Spring Boot está tentando chamar.

Você pode tentar ajustar as versões das dependências no seu arquivo pom.xml. Recomendaria manter as versões compatíveis. No seu caso, você pode tentar usar uma versão mais recente do Spring Boot, pois a versão 3.0.0-M5 pode não ser compatível com a versão mais recente do Flyway.

Aqui está uma versão modificada do seu pom.xml:

<properties>
    <java.version>17</java.version>
    <spring.boot.version>2.6.0</spring.boot.version>
    <flyway.version>7.15.0</flyway.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <version>${spring.boot.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
        <version>${spring.boot.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>${spring.boot.version}</version>
    </dependency>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
        <version>${flyway.version}</version>
    </dependency>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-mysql</artifactId>
        <version>${flyway.version}</version>
    </dependency>

    <!-- Outras dependências -->

</dependencies>

Depois de fazer essas alterações, limpe o projeto e reconstrua para garantir que as dependências sejam baixadas corretamente. Se o problema persistir, talvez seja necessário ajustar as versões das dependências de acordo com a compatibilidade.


APPLICATION FAILED TO START


Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

Action:

Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the classpath. If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

Agora deu este erro