7
respostas

Erro no flyway ao executar o projeto

Ao tentar rodar o projeto, dá este erro: console do projeto ao executar

7 respostas

Oi Felipe!

Posta o resto da exception, pois saiu cortado na imagem

(Exception parte 2 )

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-04-26T23:07:57.801-03:00 ERROR 50134 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception with message: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: URL must start with 'jdbc'
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:659) ~[spring-beans-6.0.8.jar:6.0.8]

Em "aplication.properties" tirei as aspas e deu um novo erro: Antes

spring.datasource.url="jdbc:mysql://localhost/vollmed_api"
spring.datasource.username=root
spring.datasource.password=root

Depois

spring.datasource.url=jdbc:mysql://localhost/vollmed_api
spring.datasource.username=root
spring.datasource.password=root

Erro:

***************************
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:187)

The following method did not exist:

    'org.flywaydb.core.api.configuration.FluentConfiguration org.flywaydb.core.api.configuration.FluentConfiguration.failOnMissingLocations(boolean)'

The calling method's class, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration, was loaded from the following location:

    jar:file:/home/alfa/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/3.0.6-SNAPSHOT/spring-boot-autoconfigure-3.0.6-20230420.095609-35.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:/home/alfa/.m2/repository/org/flywaydb/flyway-core/7.8.0/flyway-core-7.8.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:/home/alfa/.m2/repository/org/flywaydb/flyway-core/7.8.0/flyway-core-7.8.0.jar


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


Process finished with exit code 0

Parece que deu algum problema com as dependências que o Maven baixou.

Apague a pasta do Maven (diretório oculto .m2 localizado na pasta do seu usuário no computador) e depois clica no ícone de reload, na aba do maven no intellij, para o Maven baixar novamente as dependências do projeto.

Pra min a exclusão da pasta .m2 e o reset no maven funcionou obrigado!

obrigado deu certo pra mim tb

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software