Я получаю ошибку ниже, работая на примере Spring Boot Javers.
java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:816) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:797) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:324) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at com.example.SpringbootJaVersApplication.main(SpringbootJaVersApplication.java:37) [classes/:na]
Caused by: java.lang.ClassCastException: org.javers.core.diff.changetype.ValueChange cannot be cast to org.javers.core.diff.changetype.map.MapChange
at com.example.SpringbootJaVersApplication.withJavers(SpringbootJaVersApplication.java:118) [classes/:na]
at com.example.SpringbootJaVersApplication.run(SpringbootJaVersApplication.java:49) [classes/:na]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
... 5 common frames omitted
Код:
List<Change> snapshots = javers.findChanges(QueryBuilder.byInstanceId(c.getId(), Car.class).build());
for (Change ch : snapshots) {
if(ch instanceof ValueChange) {
System.out.println("Change is an instance of value change...");
ValueChange vc = (ValueChange) ch;
System.out.println(vc.getPropertyName());
System.out.println(vc.getAffectedGlobalId());
System.out.println(vc.getLeft()+" "+vc.getRight());
}
if(ch instanceof PropertyChange) {
PropertyChange pc = (PropertyChange)ch;
System.out.println(pc.getPropertyName());
System.out.println(pc.getAffectedGlobalId());
MapChange mc = (MapChange)pc;
System.out.println(mc.getPropertyName());
}
}