0

使用传统的运行 mongock 的方法 - https://www.mongock.io/quick-start#traditional-builder-approach

@Bean
public MongockSpring5.MongockInitializingBeanRunner changockSpring5(ApplicationContext springContext, MongoClient mongoClient) {
        SpringDataMongoV3Driver driver = SpringDataMongoV3Driver.withDefaultLock(
                new MongoTemplate(mongoClient, database));
        
        return MongockSpring5
                .builder()
                .setDriver(driver)
                .addChangeLogsScanPackage("com.abc.mongock.migration")
                .setSpringContext(springContext)
                .buildInitializingBeanRunner();
    }

我们如何将配置传递给此构建器以将“throwExceptionIfCannotObtainLock”设置为 false?

4

1 回答 1

1

我们可以通过调用“dontFailIfCannotAcquireLock”来设置它,如下所示

MongockSpring5
                .builder()
                .setDriver(driver)
                .addChangeLogsScanPackage("com.abc.mongock.migration")
                .setSpringContext(springContext)
                .dontFailIfCannotAcquireLock()
                .buildInitializingBeanRunner();
于 2021-03-30T07:33:42.307 回答