简体   繁体   中英

Quarkus + Panache + Active Record Pattern + Inheritance problem

I can create a Base class that extends PanacheMongoEntity (example below) and the Child class extending Base works as expected. However, if I move the Base class into a separate JAR file (eg, core.jar), I get an error “java.lang.IllegalStateException: This method is normally automatically overridden in subclasses” when calling Child.listAll().

public class Base extends PanacheMongoEntity {
    public String modifiedDate;
}

public class Child extends Base {
    public String name;
}

// works
Child.listAll();

As mentioned, if the Base class and Child class are compiled at the same time, it works. But moving Base to a JAR and including as a dependency does not work.

For all external jars to get scanned by Quarkus, you need to add an empty beans.xml in /src/main/resources/META-INF in your external project.

This is described somewhere on Quarkus guides.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM