在Spring Boot应用程序下面的eclipse中调试时,在表中插入记录的工作正常,但在执行findFirst时却没有,给我:failed to determine Model class name, are you sure models have been instrumented?

摇篮:

plugins {
    (...)
    id 'java'
    id "de.schablinski.activejdbc-gradle-plugin" version "1.2" apply false
}

(...)

dependencies {

    implementation group: 'org.javalite', name: 'activejdbc', version: '1.4.11'
    implementation group: 'org.javalite', name: 'activejdbc-instrumentation', version: '1.4.11'

    (...)
}

/** Task: Instrument ActiveJdbc models **/
    task activeJdbcInstrumentation() {
    apply plugin: 'de.schablinski.activejdbc-gradle-plugin'
}

build.dependsOn(activeJdbcInstrumentation)


爪哇

Base.open(dataSource);

try {
    TestConJavaLite model = new TestConJavaLite();
    model.setString("ID", UUID.randomUUID());
    model.setString("Column1", UUID.randomUUID());
    model.setString("Column2", UUID.randomUUID());
    model.setString("Column3", UUID.randomUUID());
    model.setString("Column4", UUID.randomUUID());
    model.setString("Column5", UUID.randomUUID());
    model.setString("Column5", UUID.randomUUID());
    model.setString("Column6", UUID.randomUUID());
    model.setString("Column7", UUID.randomUUID());
    model.setString("Column8", UUID.randomUUID());
    model.setString("Column9", UUID.randomUUID());
    model.insert(); // --> Works fine

    model = model.findFirst("ID = 1"); // --> Gives error
} catch (Exception e) {
    System.out.println(e.getMessage());
}

if(Base.hasConnection()) {
    Base.close();
}


我不明白的是为什么只为findFirst而不是insert给出该错误。任何的想法?

最佳答案

此处介绍了仪器的工作方式:https://javalite.io/instrumentation

基本上,检测将静态方法的字节码从类Model复制到您的类中。实例方法保持不变。 findFirst()方法是静态的,如果要使用它,则需要检测。 insert()是实例方法,因此不需要检测。

07-25 21:04