Mongock Standalone不执行变更日志

问题描述

我的项目中具有以下配置,但由于某些原因,更改日志从未执行。
关于我所缺少的任何想法吗?

我可以成功使用mongo客户端并执行CRUD操作,只是MongockStandalone无法正常工作。

pom.xml

<dependency>
    <groupId>com.github.cloudyrock.mongock</groupId>
    <artifactId>mongock-standalone</artifactId>
    <version>4.1.14</version>
</dependency>
<dependency>
    <groupId>com.github.cloudyrock.mongock</groupId>
    <artifactId>mongodb-v3-driver</artifactId>
    <version>4.1.14</version>
</dependency>
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongo-java-driver</artifactId>
    <version>3.11.0</version>
</dependency>

主类中的驱动程序代码

MongockStandalone.builder()
                 .setDriver(MongoCore3Driver.withDefaultLock(mongoClient,"demo"))
                 .addChangeLogsScanPackage("co.my.test.persistence.changelog")
                 .buildrunner();

Changelog类:

package co.my.test.persistence.changelog;

//imports

@ChangeLog(order = "001")
public class Changelog001 {

    @ChangeSet(order = "001",id = "test",author = "Igor Flakiewicz")
    public void test() {
        // this method is never executed,the sout doesn't occur and breakpoints are not reached
        System.out.println("PLEASE WORK!");
        // migration code
    }

}

解决方法

可能您正在关注blur。感谢这张票,我们已经在文档中发现了一个错误。 使用以下代码构建运行器之后:

export class SampleComponent {
  focus = false;    // <-- default value
  ...
}

您需要执行方法<div class="form__group__full"> <input (focus)="focus=true" (blur)="focus=false" type="text" class="form__field" id="callbackName" [(ngModel)]="name" placeholder="e.g. John" [ngStyle]="focus ? {'color': brand?.colours.primary,'border-bottom': '2px solid ' + brand?.colours.secondary,'border-image:focus': 'linear-gradient(to right,' + brand?.colours.primary + ',' + brand?.colours.secondary + ')'} : ''" > <label for="callbackName" class="form__label">Name</label> </div>

因此,您应该使用的正确代码如下:

MongockStandalone.builder()
             .setDriver(MongoCore3Driver.withDefaultLock(mongoClient,"demo"))
             .addChangeLogsScanPackage("co.my.test.persistence.changelog")
             .buildRunner();

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...