“StackTrace”:“java.lang.IllegalStateException:没有为持久化单元定义池default-reactive\n\tat io.quarkus.hibernate.reactive.runtime.fastboothibernateReactive.RegisterVertXandpool(fastboothibernateReactive.RegisterVerteProvider.java:233)\n\tat io.quarkus.hibernate.reactive.RegisterVerteProvider.java:233 ereActivePersistenceProvider.getEntityManagerFactoryBuilderornull(fastboothibernateReactivePersistenceProvider.java:156)\n\tat io.quarkus.hibernate.reactive.runtime.fastboothibernateReactive.createEntityManagerFactory(fastboothibernate.createEntityManagerFactoryrnate.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.jtal.$$superaccessor5(jpaconfig_subclass.zig:769)\n\tat arc.impl.aroundInvokeInvocationContext.proce(aroundInvokeInvocationContext.java:54)\n\tat io.quarkus.arc.runtime.devconsole.invocationInterceptor.proce(invocationInterceptor.java:62)\n\tat io.quarkus.arc.runtime.devconsole.invocationInterceptor.monitor(invocationInterceptor.java:62)\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 6026.zig:74)\n\tat io.quarkus.deployment.steps.hibernateormProcessor$startpersistenceUnits951856026.deploy(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 quarkus.java:66)\n\tat io.quarkus.runtime.quarkus.run(quarkus.java:42)\n\tat io.quarkus.runtime.quarkus.run(quarkus.java:119)\n\tatio.quarkus.runner.generatedmain.main(generatedmain.zig:29)\n\tat java.base/jdk.internal.reflect.nativeMethodAccessorimpl.invoke0(原生方法)\n\tat ap.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
在我的例子中,我试图使用H2分贝,我得到了同样的问题。我使用一种基于地图的方法解决了这个问题,如下所示:
来自:
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:guitars
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.packages=package br.com.mp.product.models
致:
quarkus.datasource."guitars".db-kind=h2
quarkus.datasource."guitars".jdbc.url=jdbc:h2:mem:guitars
quarkus.hibernate-orm."guitars".database.generation=drop-and-create
quarkus.hibernate-orm."guitars".packages=package br.com.mp.product.models