当前位置: 首页 > 知识库问答 >
问题:

在docker上部署时创建mongock bean出错

邹星火
2023-03-14

我正在使用Mongck迁移Spring Boot应用程序中的数据。Spring Boot应用程序在本地运行良好。但在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类的内容:

    @Bean
    public MongockSpring5.MongockInitializingBeanRunner mongockInitializingBeanRunner(ApplicationContext springContext, MongoTemplate mongoTemplate) {
        boolean migrationsEnabled = mongoEnabled;
        return MongockSpring5.builder()
                .setDriver(SpringDataMongoV3Driver.withDefaultLock(mongoTemplate))
                .addChangeLogsScanPackages(List.of(changeLogsScanPackage))
                .setSpringContext(springContext)
                .setEnabled(migrationsEnabled)
                .buildInitializingBeanRunner();
    }

我不明白为什么它在docker上运行时不起作用。我的mongockInitializingBeanRunner方法是否不正确。

谁来帮帮我

共有1个答案

敖硕
2023-03-14

如本Github问题所述,该问题已通过升级到版本4.3.7得到解决。

 类似资料:
  • 我想在heroku上有一个tilestream,我遵循了教程,我做了完全相同的事情,并不断得到一个构建/编译错误。 刚刚添加了2个文件和一个目录: Procfile: 包裹json: 空的/平铺方向。 当通过git推送到heroku时,我得到以下错误: 当我去网站时,我得到了错误(检查这里) 我还检查了日志: 以及在heroku上运行的进程: 对于这个例子,我没有将地图上传到./ware目录,但是

  • 我尝试用java做一个rest web服务,并使用OpenShift服务测试服务器。 在OpenShift中,我选择Tomcat 7(JBoss EWS 2.0)作为web服务器。 当我试图将我的文件推入服务器时,在maven构建时,它会给我这些错误: 似乎错误是关于我的tools.java文件。 所以这是我的工具.java文件的代码: 我想知道,因为当我在我的PC中使用命令时,没有错误并且项目完

  • 我已经尝试了很多东西来部署这个功能,安装和卸载节点多次和更多的尝试,但它仍然给我同样的错误。我试图实现的是使用agora-Access令牌包生成令牌使用Firebase函数代码是: 错误是: ===部署到'xxxx'... 我部署函数运行命令: npm--prefix"$RESOURCE_DIR"run lint 皮棉。 函数:完成预部署脚本的运行。i函数:确保启用所需的APIcloudfunct

  • 无法在weblogic服务器上部署jersey REST,是否存在特定于weblogic的REST服务配置? 完全堆栈跟踪- 2018年4月25日下午7:01:53。太阳运动衫服务器impl。应用WebApplicationImpl启动信息:启动泽西岛应用程序,版本“泽西岛:1.2 05/07/2010 02:11 PM”2018年4月25日7:01:53 PM com。太阳运动衫服务器impl。

  • 我在jboss EAP6.4服务器上部署ear文件时遇到问题。下面是原木。请帮帮忙。 13:21:39,000信息[org.jboss.as.server.deployment.scanner](deploymentscanner-threads-2)JBAS015003:在部署目录中找到process-engine.ear。要触发部署,请创建一个名为process-engine.ear.dode

  • 我在springboot应用程序中有筛选器。在embedded tomcate 9.0.34中运行该应用程序时,它可以正常工作。然而,当我创建war并将其部署在外部Tomcate8.5上时,它会抛出以下错误。