是否可以将 jOOQ 与 Quarkus 一起使用?
Is it possible to use jOOQ with 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.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?
我发现这个 repo 有一个使用 jOOQ 和 Quarkus 的例子,它让我克服了上面的错误:https://github.com/jean-merelis/jOOQ-mcve.
我所做的更改是:
- 的class
添加了类似 https://github.com/jean-merelis/jOOQ-mcve/blob/master/src/main/resources/reflection-config.json
的配置文件
更新 2022-01-13
https://github.com/quarkiverse/quarkus-jooq 上有一个 Quarkus 的“官方”jOOQ 扩展,该扩展于 2021 年 2 月开始。
我很好奇 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.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?
我发现这个 repo 有一个使用 jOOQ 和 Quarkus 的例子,它让我克服了上面的错误:https://github.com/jean-merelis/jOOQ-mcve.
我所做的更改是:
- 的class
添加了类似 https://github.com/jean-merelis/jOOQ-mcve/blob/master/src/main/resources/reflection-config.json
的配置文件
更新 2022-01-13
https://github.com/quarkiverse/quarkus-jooq 上有一个 Quarkus 的“官方”jOOQ 扩展,该扩展于 2021 年 2 月开始。