Spring boot 在docker上部署时创建Mongockbean时出错

Spring boot 在docker上部署时创建Mongockbean时出错,spring-boot,mongock,Spring Boot,Mongock,我正在使用Mongck迁移Spring Boot应用程序中的数据。Spring启动应用程序可以在本地完美运行。但在docker上运行时,会发生以下错误: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongockInitializingBeanRunner' defined in class path resource [vn/vnpt/icode/svc/conf

我正在使用Mongck迁移Spring Boot应用程序中的数据。Spring启动应用程序可以在本地完美运行。但在docker上运行时,会发生以下错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongockInitializingBeanRunner' defined in class path resource [vn/vnpt/icode/svc/config/config/MongockConfig.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/mongodb/MongoDatabaseFactory

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]

查看完整日志

以下是build.gradle文件中的依赖项:

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-cache'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-data-rest'
    implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
    implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'javax.xml.bind:jaxb-api'
    
    implementation 'com.github.cloudyrock.mongock:mongock-bom:4.3.7'
    implementation 'com.github.cloudyrock.mongock:mongodb-springdata-v3-driver:4.3.7'
    implementation 'com.github.cloudyrock.mongock:mongock-spring-v5:4.3.7'


    
    
    implementation 'com.hazelcast:hazelcast-kubernetes:2.0'
    implementation 'com.hazelcast:hazelcast-spring'
    implementation 'org.springframework.cloud:spring-cloud-starter-stream-kafka:3.0.1.RELEASE'
    
//    implementation 'org.apache.poi:poi-ooxml:4.1.1'
    implementation 'org.apache.commons:commons-collections4:4.1'
    implementation 'com.google.code.gson:gson'
    implementation 'org.json:json:20201115'
    
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
以及MongockConfig类的内容:

@豆子 public MongockSpring5.MongockInitializingBeanRunner MongockInitializingBeanRunner应用程序上下文springContext,MongoTemplate MongoTemplate{ boolean MigrationEnabled=mongoEnabled; 返回MongockSpring5.builder .setDriverSpringDataMongoV3Driver.withDefaultLockmongoTemplate .AddChangeLogsCanPackageList.OfChangeLogsCanPackage .setSpringContextspringContext .SetEnabledMigrationEnabled .buildInitializingBeanRunner; } 我不明白为什么在docker上运行时它不工作。我的mongockInitializingBeanRunner方法不正确

有人请帮助我

如本文所述,通过升级到4.3.7版解决了此问题