我目前正在开发一个 Quarkus 微服务,它必须对 ActiveMQ Artemis 队列上的 AMQP 消息做出反应。此类消息包含类型在第三方库中定义的有效负载,因此我必须将此库作为 Maven 依赖项导入。但是,此类库还包含一个 JPA 持久性单元(通过此类库中包含的 persistence.xml
文件定义),在启动时由 Quarkus 扫描,导致以下错误:
Caused by: io.quarkus.deployment.configuration.ConfigurationError: Unable to properly register the hierarchy of the following JPA classes as they are not in the Jandex index:
- org.dependency.SomeEntity
Consider adding them to the index either by creating a Jandex index for your dependency via the Maven plugin, an empty META-INF/beans.xml or quarkus.index-dependency properties.
at io.quarkus.hibernate.orm.deployment.JpaJandexScavenger.discoverModelAndRegisterForReflection(JpaJandexScavenger.java:116)
at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.defineJpaEntities(HibernateOrmProcessor.java:351)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:972)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:830)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
由于我对管理这些实体不感兴趣,有没有办法指示 JPA 扫描器忽略特定包,或者更好的是,只查找特定包中的持久性单元?