I am upgrading my java to version 17(spring boot version-3.0.4), but I need to use flyway-core dependency as 6.5.7 only as it is the last flyway version available that supports mysql 5.7(which I need to use in my project).
But when I run my junits I get below error:-
An attempt was made to call a method that does not exist. The attempt was made from the following location:
我正在升级我的java到17版(spring boot version-3.0.4),但是我需要使用flyway-core dependency as 6.5.7,因为它是最后一个支持mysql 5.7的flyway版本(我需要在我的项目中使用)。但是当我运行我的junits时,我得到下面的错误:-试图调用一个不存在的方法。从以下位置进行了尝试:
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:
调用方法的类org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration,是从以下位置加载的:
jar:file:/C:/Users/sx8428/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/3.0.4/spring-boot-autoconfigure-3.0.4.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:
被调用方法的类org.flywaydb.core.api.configuration.FluentConfiguration,可从以下位置获得:
jar:file:/C:/Users/sx8428/.m2/repository/org/flywaydb/flyway-core/7.5.4/flyway-core-7.5.4.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/sx8428/.m2/repository/org/flywaydb/flyway-core/7.5.4/flyway-core-7.5.4.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
更正应用程序的类路径,使其包含org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration和org.flywaydb.core.api.configuration.FluentConfiguration类的兼容版本
I need to find a way to exclude spring from automatically configuring flyway version.
我需要找到一种方法,从自动配置Flyway版本中排除弹簧。
更多回答
Can you please also share specific problem that you have when using flyway version compatible with Spring Boot version that you use. Not sure how does this affect mysql version.
你也可以分享你在使用与你使用的Spring Boot版本兼容的flyway版本时遇到的具体问题。不知道这对mysql版本有什么影响。
Sorry, I meant 6.5.7 is the last flyway version that supports mysql 5.7. Edited my question.
对不起,我的意思是6.5.7是最后一个支持MySQL5.7的Flyway版本。编辑了我的问题。
优秀答案推荐
To disable Spring using FlywayAutoConfiguration, set spring.flyway.enabled=false
(see here).
要使用Flyway AutoConfiguration禁用Spring,请将spring.flyway.Enabled设置为False(请参见此处)。
If you want to find an older version of FlywayAutoConfiguration that behaves as you want, then try looking through the old versions here and copy it into you project.
You will need to remove this from your copy:
如果你想找到一个你想要的Flyway AutoConfiguration的旧版本,那么试着在这里浏览旧版本并将其复制到你的项目中。您需要从副本中删除以下内容:
@ConditionalOnProperty(prefix = "spring.flyway", name = "enabled", matchIfMissing = true)
Here's a solution for you problem
这里有一个解决你问题的办法
The latest version of Community Flyway that supports MySQL 5.7 is indeed 7.15.0
The latest version of Spring that supports version of Flyway up to 7.15.0 is 2.5.x
Therefore, what you can do is to use version of Flyway 7.7.3 and copy flyway folder from that version of Spring to your source code.
Everything else from Spring will be from original version and only Flyway will be replaced.
因此,您可以做的是使用Flyway 7.7.3版本,并将flyway文件夹从该版本的Spring复制到您的源代码中。Spring中的其他所有内容都将来自原始版本,只有Flyway将被替换。
更多回答
Along with copying the configuration, Do I need to add any dependency too because few imports are not resolved I can see? Like org.springframework.boot.autoconfigure.data.jpa.EntityManagerFactoryDependsOnPostProcessor
在复制配置的同时,我是否还需要添加任何依赖项,因为我可以看到很少有导入没有得到解决?像org.springframework.boot.autoconfigure.data.jpa.EntityManagerFactoryDependsOnPostProcessor一样
Are you sure you need all this, since when I tried creating a spring boot project, it automatically added an additional dependency on flyway-mysql
? Do you just need to add this as an extra dependency, so it doesn't seem that it was a part of flyway-core
anyway? It still seems to be a thing on their website: flywaydb.org/mysql
你确定你需要所有这些吗,因为当我尝试创建一个Spring Boot项目时,它自动添加了对Flyway-MySQL的额外依赖?您是否只需要将其添加为额外的依赖项,这样它看起来就不像是Flyway-core的一部分了?这似乎仍然是他们网站上的一件事:flywaydb.org/mysql
我是一名优秀的程序员,十分优秀!