我正在尝试使用 Reactive jackson hibernate panache mysql 作为 DB 构建一个小应用程序。
我收到以下错误。
"stackTrace": "java.lang.IllegalStateException: 没有为持久性单元默认反应定义池\n\tat io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.registerVertxAndPool(FastBootHibernateReactivePersistenceProvider.java:233)\n\tat io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.rewireMetadataAndExtractServiceRegistry(FastBootHibernateReactivePersistenceProvider.java:180)\n\tat io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.getEntityManagerFactoryBuilderOrNull(FastBootHibernateReactivePersistenceProvider.io:56)\n\tat quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.createEntityManagerFactory(FastBootHibernateReactivePersistenceProvider.java:82)\n\tat javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)\n\tat javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)\n\tat io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig. java:118)\n\tat io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:42)\n\tat io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass.startAll$$superaccessor5(JPAConfig_Subclass .zig:769)\n\tat io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass$$function$$5.apply(JPAConfig_Subclass$$function$$5.zig:29)\n\tat io.quarkus.arc.impl .AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)\n\tat io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)\n\tat io.quarkus.arc.runtime.devconsole.InvocationInterceptor .monitor(InvocationInterceptor.java:51)\n\tat io。quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)\n\tat io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)\n\tat io.quarkus.arc。 impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)\n\tat io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)\n\tat io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass。 startAll(JPAConfig_Subclass.zig:727)\n\tat io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder.startAllPersistenceUnits(HibernateOrmRecorder.java:88)\n\tat io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits951856026.deploy_0( HibernateOrmProcessor$startPersistenceUnits951856026.zig:74)\n\tat io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits951856026。部署(HibernateOrmProcessor$startPersistenceUnits951856026.zig:40)\n\tat io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:751)\n\tat io.quarkus.runtime.Application.start(Application.java:90) \n\tat io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:100)\n\tat io.quarkus.runtime.Quarkus.run(Quarkus.java:66)\n\tat io.quarkus.runtime。 Quarkus.run(Quarkus.java:42)\n\tat io.quarkus.runtime.Quarkus.run(Quarkus.java:119)\n\tat io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29) \n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)\n\tat java .base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:567)\n\tat io.quarkus.runner.bootstrap.StartupActionImpl$3.run(StartupActionImpl.java:134)\n\tat java.base/java.lang.Thread.run (Thread.java:831)\n"
知道缺少什么吗?
我有模型
@Entity
public class Nation extends PanacheEntity {
@Column
public String country;
public Nation(String country, List<State> states) {
this.country = country;
this.states = states;
}
@OneToMany(cascade = {CascadeType.ALL})
public List<State> states = new ArrayList<>();
public Nation() {
}
}
@Entity
public class State extends PanacheEntity {
public State(String state, List<District> districts) {
this.state = state;
this.districts = districts;
}
@Column
public String state;
@OneToMany
public List<District> districts = new ArrayList<>();
public State() {
}
}
@Entity
public class District extends PanacheEntity {
public District(String district, List<Village> villages) {
this.district = district;
this.villages = villages;
}
@Column
public String district;
@OneToMany
public List<Village> villages = new ArrayList<>();
public District() {
}
}
@Entity
public class Village extends PanacheEntity {
@Column
public String village;
public Village(String village) {
this.village = village;
}
public Village() {
}
}
@Path("/nation")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ApplicationScoped
public class NationResource {
@Inject
NationRepository nationRepository;
/* @Inject
public NationResource(NationRepository nationRepository) {
this.nationRepository = nationRepository;
}*/
@POST
@Path("save")
public Uni<Void> saveNation(Nation nation) {
return nationRepository.persist(nation);
}
@GET
public Uni<List<Nation>> getNations() {
return nationRepository.listAll();
}
@GET
@Path("{id}")
public Uni<Nation> getNation(@PathParam("id") Long id) {
return nationRepository.findById(id);
}
}
quarkus:
http:
port: 4754
log:
console:
json:
pretty-print: true
date-format: "YYYY-MM-dd HH:mm:ss"
exception-output-type: "detailed-and-formatted"
# configure your datasource
datasource:
db-kind: mysql
username: root
password: root
reactive:
url: vertx-reactive:mysql://localhost:3306/garrsolutions
# drop and create the database at startup (use `update` to only update the schema)
hibernate-orm:
database:
generation: drop-and-create