Quarkus 不满足类型的依赖性。使用扩展

Quarkus Unsatisfied dependency for type. Using Extension

我有下一个结构:

  1. 带有接口 SomeInterface 和 bean SomeContainer:

    的 Quarkus 扩展 'core'
     @ApplicationScoped
     public class SomeContainer {
    
       @Inject
       SomeInterface someInterface;
     }
    
  2. 带有 SomeImpl bean 的 Quarkus 扩展 'implementation':

     @ApplicationScoped
     public class SomeImpl implements SomeInterface {
    
     }
    
  3. Quarkus 应用程序 - 'starter' 依赖于 quarkus 扩展 'implementation' 和 jax rs 控制器:

     @Path("/hello")
     public class GreetingResource {
    
       @Inject
       SomeContainer someContainer;
    
       @GET
       @Produces(MediaType.TEXT_PLAIN)
       public String hello() {
    
       }
    }
    

当我尝试启动应用程序时出现错误:

Caused by: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type by.test.core.SomeInterface and qualifiers [@Default]

如何解决? link 到项目 https://github.com/flagmen/quarkus-test

您的 starter 模块仅依赖于 core 模块,该模块本身不包含 [=11= 的 CDI 可注射候选者].

您应该添加 实现 模块将可发现的 bean 也作为依赖项保存:

<!-- quarkus-test/starter/pom.xml -->
<dependencies>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-resteasy</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-junit5</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>rest-assured</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>by.test</groupId>
        <artifactId>core</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>by.test</groupId>
        <artifactId>implementation</artifactId> <!-- you can even omit the core module as it will be transitively imported -->
        <version>1.0.0</version>
    </dependency>
</dependencies>