Quarkus不满足类型的依赖关系.使用扩展



我有下一个结构:

  1. 带有接口SomeInterface和beanSomeContainer的Quarkus扩展"核心":

    @ApplicationScoped
    public class SomeContainer {
    @Inject
    SomeInterface someInterface;
    }
    
  2. Quarkus扩展"实现"与SomeImplbean:

    @ApplicationScoped
    public class SomeImpl implements SomeInterface {
    }
    
  3. Quarkus应用程序-依赖于Quarkus扩展"实现"和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]

如何修复?链接到项目https://github.com/flagmen/quarkus-test

您的starter模块仅依赖于core,该模块本身不包含SomeInterface的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>

最新更新