Java SE + Apache DeltaSpike:不满足类型存储库的依赖关系

Java SE + Apache DeltaSpike: Unsatisfied dependencies for type Repository

我正在尝试使用 DeltaSpike Data module with Weld, but every class annotated with @Repository 在我的 IDE 中显示警告并在运行时出现异常。

我试过 DeltaSpike documentation numerous times, checked Baeldung 和各种 articles/forums 但没有找到解决方案。

有谁知道我可能缺少什么才能正确注入存储库?

IDE警告

Managed Bean must be a concrete class or @Decorator

运行时异常

org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type ExampleRepo with qualifiers @Default
  at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject public com.example.myapp.services.ExampleService(ExampleRepo)

示例存储库

@Repository(forEntity = Data.class)
public interface ExampleRepo extends EntityRepository<Example, Long> {

    Data findExampleById(long id);

    @Modifying
    @Query("UPDATE Data AS e SET e.locale = ?1 WHERE e.id = ?2")
    int updateLocale(final Locale locale, final long id);

    @Modifying
    @Query("UPDATE Data AS g SET g.reactTranslation = ?1 WHERE g.id = ?2")
    int updateReactTranslation(final boolean toggle, final long id);
}

Gradle

plugins {
    id "io.spring.dependency-management" version "1.0.8.RELEASE"
}

ext {
    deltaSpikeVersion = "1.9.2"
}

dependencies {
    // DeltaSpike Extensions
    implementation "org.apache.deltaspike.modules:deltaspike-data-module-api:${deltaSpikeVersion}"
    runtimeOnly "org.apache.deltaspike.modules:deltaspike-data-module-impl:${deltaSpikeVersion}"
    implementation "org.apache.deltaspike.modules:deltaspike-scheduler-module-api:${deltaSpikeVersion}"
    runtimeOnly "org.apache.deltaspike.modules:deltaspike-scheduler-module-impl:${deltaSpikeVersion}"

    // Database
    implementation "org.hibernate:hibernate-core:${hibernateVersion}"
    implementation "org.hibernate:hibernate-c3p0:${hibernateVersion}"
    runtimeOnly "mysql:mysql-connector-java:8.0.18"
}

dependencyManagement {
    imports {
        mavenBom "org.apache.deltaspike.distribution:distributions-bom:${deltaSpikeVersion}"
    }
}

澄清一下,以下也是项目的隐式依赖。

我错过了 Java SE 特定说明: https://deltaspike.apache.org/documentation/cdiimp.html#javase6

我不得不使用 DeltaSpike 的 CdiContainer 而不是 Weld 的 SeContainer

dependencies {
    implementation "org.apache.deltaspike.cdictrl:deltaspike-cdictrl-api:${deltaSpikeVersion}"
    runtimeOnly "org.apache.deltaspike.cdictrl:deltaspike-cdictrl-weld:${deltaSpikeVersion}"
}