是否可以在Quarkus中使用jOOQ?

时间:2020-03-01 14:34:04

标签: jooq quarkus

我很好奇jOOQ是否可以与Quarkus一起工作,所以我创建了一个Gradle项目。我收到此构建错误:

Caused by: io.quarkus.creator.AppCreatorException: Failed to augment application classes
        at io.quarkus.creator.phase.augment.AugmentTask.run(AugmentTask.java:188)
        at io.quarkus.creator.phase.augment.AugmentTask.run(AugmentTask.java:53)
        at io.quarkus.creator.CuratedApplicationCreator.runTask(CuratedApplicationCreator.java:139)
        at io.quarkus.gradle.tasks.QuarkusBuild.buildQuarkus(QuarkusBuild.java:91)
        ... 92 more
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.jooq.DSLContext and qualifiers [@Default]
        - java member: com.hexarchbootdemo.adapter.output.persistence.h2.VoterPersistenceH2Adapter#<init>()
        - declared on CLASS bean [types=[com.hexarchbootdemo.application.port.output.persistence.FindVoterPort, com.hexarchbootdemo.adapter.output.persistence.h2.VoterPersistenceH2Adapter, com.hexarchbootdemo.application.port.output.persistence.RegisterVoterPort, java.lang.Object], qualifiers=[@Named(value = "voterPersistenceH2Adapter"), @Default, @Any], target=com.hexarchbootdemo.adapter.output.persistence.h2.VoterPersistenceH2Adapter]
        at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:879)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:231)
        at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:117)
        at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:272)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:915)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:279)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.jooq.DSLContext and qualifiers [@Default]
        - java member: com.hexarchbootdemo.adapter.output.persistence.h2.VoterPersistenceH2Adapter#<init>()
        - declared on CLASS bean [types=[com.hexarchbootdemo.application.port.output.persistence.FindVoterPort, com.hexarchbootdemo.adapter.output.persistence.h2.VoterPersistenceH2Adapter, com.hexarchbootdemo.application.port.output.persistence.RegisterVoterPort, java.lang.Object], qualifiers=[@Named(value = "voterPersistenceH2Adapter"), @Default, @Any], target=com.hexarchbootdemo.adapter.output.persistence.h2.VoterPersistenceH2Adapter]

我尝试将DI提示(https://quarkus.io/guides/cdi-reference)添加到application.properties,但这没什么区别。

quarkus.index-dependency.jooq.group-id=org.jooq
quarkus.index-dependency.jooq.artifact-id=jooq

jOOQ依赖存在:

compileClasspath - Compile classpath for compilation 'main' (target  (jvm)).
+--- org.springframework.boot:spring-boot-starter-jooq:2.2.3.RELEASE
|    +--- org.springframework.boot:spring-boot-starter-jdbc:2.2.3.RELEASE
...
...
|    \--- **org.jooq:jooq:3.12.3**

是否可以使用jOOQ和Quarkus?

1 个答案:

答案 0 :(得分:0)

我通过使用jOOQ和Quarkus的示例找到了这个仓库,它使我摆脱了上面的错误:https://github.com/jean-merelis/jOOQ-mcve

我所做的更改是:

  1. 添加了类似于https://github.com/jean-merelis/jOOQ-mcve/blob/master/src/main/java/org/jooq/mcve/JooqContextProducer.java

  2. 的类
  3. 添加了类似的配置文件,例如https://github.com/jean-merelis/jOOQ-mcve/blob/master/src/main/resources/reflection-config.json