Error connecting Flyway in spring application

Asked

Viewed 365 times

0

Configuration of the POM:

pom.xml

Application properties:

inserir a descrição da imagem aqui

Error while running project:

inserir a descrição da imagem aqui

2019-12-19 11:23:27.844 ERROR 22884 --- [ restartedMain] o.s.boot.Springapplication : Application startup failed

org.springframework.Beans.factory.Beancreationexception: Error Creating bean with name 'flywayInitializer' defined in class path Resource [org/springframework/boot/autoconfigure/flyway/Flywayautoconfiguration$Flywayconfiguration.class]: Invocation of init method failed; nested Exception is org.flywaydb.core.api.Flywayexception: Unable to obtain Jdbc Connection from Datasource at org.springframework.Beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(Abstractautowirecapablebeanfactory.java:1578) ~[spring-Beans-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.Beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(Abstractautowirecapablebeanfactory.java:545) ~[spring-Beans-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.Beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(Abstractautowirecapablenfactory.java:482) ~[spring-Beans-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.Beans.factory.support.Abstractbeanfactory$1.getObject(Abstractbeanfactory.java:306) ~[spring-Beans-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.Beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(Defaultsingletonbeanregistry.java:230) ~[spring-Beans-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.Beans.factory.support.AbstractBeanFactory.doGetBean(Abstractbeanfactory.java:302) ~[spring-Beans-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.Beans.factory.support.AbstractBeanFactory.getBean(Abstractbeanfactory.java:197) ~[spring-Beans-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.Beans.factory.support.AbstractBeanFactory.doGetBean(Abstractbeanfactory.java:296) ~[spring-Beans-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.Beans.factory.support.AbstractBeanFactory.getBean(Abstractbeanfactory.java:197) ~[spring-Beans-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.context.support.Abstractapplicationcontext.getBean(Abstractapplicationcontext.java:1054) ~[spring-context-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.context.support.Abstractapplicationcontext.finishBeanFactoryInitialization(Abstractapplicationcontext.java:829) ~[spring-context-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.context.support.Abstractapplicationcontext.refresh(Abstractapplicationcontext.java:538) ~[spring-context-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.boot.context.Embedded.EmbeddedWebApplicationContext.refresh(Embeddedwebapplicationcontext.java:118) ~[spring-boot-1.3.6.RELEASE. jar:1.3.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(Springapplication.java:760) [spring-boot-1.3.6.RELEASE. jar:1.3.6.RELEASE] at org.springframework.boot.SpringApplication.createAndRefreshContext(Springapplication.java:360) [spring-boot-1.3.6.RELEASE. jar:1.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(Springapplication.java:306) [spring-boot-1.3.6.RELEASE. jar:1.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(Springapplication.java:1185) [spring-boot-1.3.6.RELEASE. jar:1.3.6.RELEASE] at org.springframework.boot.SpringApplication.run(Springapplication.java:1174) [spring-boot-1.3.6.RELEASE. jar:1.3.6.RELEASE] at com.algaworks.Wine.WineApplication.main(Wineapplication.java:10) [classes/:na] at sun.reflect..Nativemethodaccessorimpl.invoke0(Native Method) ~[na:1.8.0_232] at sun.reflect..Nativemethodaccessorimpl.invoke(Nativemethodaccessorimpl.java:62) ~[na:1.8.0_232] at sun.reflect.Delegatingmethodaccessorimpl.invoke(Delegatingmethodaccessorimpl.java:43) ~[na:1.8.0_232] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_232] at org.springframework.boot.devtools.Restart.RestartLauncher.run(Restartlauncher.java:49) [spring-boot-devtools-1.3.6.RELEASE. jar:1.3.6.RELEASE] Caused by: org.flywaydb.core.api.Flywayexception: Unable to obtain Jdbc Connection from Datasource at org.flywaydb.core.internal.util.jdbcutils.openConnection(Jdbcutils.java:56) ~[flyway-core-3.2.1.jar:na] at org.flywaydb.core.Flyway.execute(Flyway.java:1385) ~[flyway-core-3.2.1.jar:na] at org.flywaydb.core.Flyway.migrate(Flyway.java:1006) ~[flyway-core-3.2.1.jar:na] at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(Flywaymigrationinitializer.java:66) ~[spring-boot-autoconfigure-1.3.6.RELEASE. jar:1.3.6.RELEASE] at org.springframework.Beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(Abstractautowirecapablebeanfactory.java:1637) ~[spring-Beans-4.2.7.RELEASE. jar:4.2.7.RELEASE] at org.springframework.Beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(Abstractautowirecapablebeanfactory.java:1574) ~[spring-Beans-4.2.7.RELEASE. jar:4.2.7.RELEASE] ... 23 common frames omitted Caused by: com.mysql.jdbc.exceptions.jdbc4.Mysqlnontransientconnectionexception: Could not create Connection to database server. at sun.reflect.Nativeconstructoraccessorimpl.newInstance0(Native

1 answer

0

This is a bug (mentioned here and here) already known for the version 5.1.39 of the Mysql driver.

Update your Mysql driver to version 5.1.41 as recommended in the bug, this version has the fix for this problem.

To complement, the problem can be identified by this part of the stacktrace:

Caused by: java.lang.Nullpointerexception: null at com.mysql.jdbc.ConnectionImpl.getServerCharset(Connectionimpl.java:2997) ~[mysql-Connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(Mysqlio.java:1936) ~[mysql-Connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(Mysqlio.java:1865) ~[mysql-Connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.MysqlIO.doHandshake(Mysqlio.java:1228) ~[mysql-Connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.ConnectionImpl.coreConnect(Connectionimpl.java:2253) ~[mysql-Connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(Connectionimpl.java:2284) ~[mysql-Connector-java-5.1.39.jar:5.1.39]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.