不是REST客户端接口:接口myclient。在班级或任何方法上都找不到@Path注释。...[Quarkus]

发布于 2025-01-23 17:11:41 字数 2825 浏览 0 评论 0原文

我有一个消耗API的项目,并且正在努力将其剩余客户注入我的服务。
是什么问题

(请注意,我主要在做另一个有效的实例中所做的事情,但是我无法确定我的客户界面


@org.eclipse.microprofile.rest.client.inject.RegisterRestClient(
  configKey = "my.feature-service.baseUrl"
)
@org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders(MyCustomHeadersFactory.class)
@javax.ws.rs.Consumes({"application/vnd.cust.my-service-config+json;version=1.0;charset=UTF-8"})
@javax.ws.rs.Produces({"application/vnd.cust.my-service-config+json;version=1.0;charset=UTF-8"})
public interface FeatureServiceClient {
  @javax.ws.rs.GET
  @javax.ws.rs.Path("/v1/my/feature")
  Uni<List<MyDto>> getPossibleFeatures();
  //and several other methods
}

:在我的消费方面:


@javax.enterprise.context.ApplicationScoped
public class MyService {

  @org.eclipse.microprofile.rest.client.inject.RestClient
  FeatureServiceClient serviceClient;

}

但是,当它试图初始化时,我我得到了:


Caused by: java.lang.IllegalArgumentException: Not a REST client interface: interface my.feature.FeatureServiceClient. No @Path annotation found on the class or any methods of the interface and no HTTP method annotations (@POST, @PUT, @GET, @HEAD, @DELETE, etc) found on any of the methods
    at org.jboss.resteasy.reactive.client.impl.ClientProxies.get(ClientProxies.java:26)
    at org.jboss.resteasy.reactive.client.impl.WebTargetImpl.proxy(WebTargetImpl.java:382)
    at io.quarkus.rest.client.reactive.runtime.RestClientBuilderImpl.build(RestClientBuilderImpl.java:273)
    at io.quarkus.rest.client.reactive.runtime.RestClientCDIDelegateBuilder.build(RestClientCDIDelegateBuilder.java:76)
    at io.quarkus.rest.client.reactive.runtime.RestClientCDIDelegateBuilder.createDelegate(RestClientCDIDelegateBuilder.java:57)
    at io.quarkus.rest.client.reactive.runtime.RestClientReactiveCDIWrapperBase.<init>(RestClientReactiveCDIWrapperBase.java:16)
    at my.feature.MyFeatureClient$$CDIWrapper.<init>(FeatureServiceClient$$CDIWrapper.zig:21)
    at my.feature.MyFeatureClient$$CDIWrapper_ClientProxy.<init>(MyFeatureClient$$CDIWrapper_ClientProxy.zig:28)
    at my.feature.MyFeatureClient$$CDIWrapper_Bean.proxy(FeatureServiceClient$$CDIWrapper_Bean.zig:40)
    at my.feature.MyFeatureClient$$CDIWrapper_Bean.get(FeatureServiceClient$$CDIWrapper_Bean.zig:243)
    at my.feature.MyFeatureClient$$CDIWrapper_Bean.get(FeatureServiceClient$$CDIWrapper_Bean.zig:259)
    at my.consumer.Myservice_Bean.create(MyService_Bean.zig:175)
    ... 67 more
    <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
    <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
    <quarkus.platform.version>2.3.0.CR1</quarkus.platform.version>

I have a project that consumes an api and am struggling to get the Rest Client injected into my service.
(to note, i am mainly doing what i did in another instance that works however I can't pinpoint what's wrong here to make this one fail)

My Client interface:


@org.eclipse.microprofile.rest.client.inject.RegisterRestClient(
  configKey = "my.feature-service.baseUrl"
)
@org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders(MyCustomHeadersFactory.class)
@javax.ws.rs.Consumes({"application/vnd.cust.my-service-config+json;version=1.0;charset=UTF-8"})
@javax.ws.rs.Produces({"application/vnd.cust.my-service-config+json;version=1.0;charset=UTF-8"})
public interface FeatureServiceClient {
  @javax.ws.rs.GET
  @javax.ws.rs.Path("/v1/my/feature")
  Uni<List<MyDto>> getPossibleFeatures();
  //and several other methods
}

on my consuming side I have:


@javax.enterprise.context.ApplicationScoped
public class MyService {

  @org.eclipse.microprofile.rest.client.inject.RestClient
  FeatureServiceClient serviceClient;

}

however when it tries to get initialised I am getting:


Caused by: java.lang.IllegalArgumentException: Not a REST client interface: interface my.feature.FeatureServiceClient. No @Path annotation found on the class or any methods of the interface and no HTTP method annotations (@POST, @PUT, @GET, @HEAD, @DELETE, etc) found on any of the methods
    at org.jboss.resteasy.reactive.client.impl.ClientProxies.get(ClientProxies.java:26)
    at org.jboss.resteasy.reactive.client.impl.WebTargetImpl.proxy(WebTargetImpl.java:382)
    at io.quarkus.rest.client.reactive.runtime.RestClientBuilderImpl.build(RestClientBuilderImpl.java:273)
    at io.quarkus.rest.client.reactive.runtime.RestClientCDIDelegateBuilder.build(RestClientCDIDelegateBuilder.java:76)
    at io.quarkus.rest.client.reactive.runtime.RestClientCDIDelegateBuilder.createDelegate(RestClientCDIDelegateBuilder.java:57)
    at io.quarkus.rest.client.reactive.runtime.RestClientReactiveCDIWrapperBase.<init>(RestClientReactiveCDIWrapperBase.java:16)
    at my.feature.MyFeatureClient$CDIWrapper.<init>(FeatureServiceClient$CDIWrapper.zig:21)
    at my.feature.MyFeatureClient$CDIWrapper_ClientProxy.<init>(MyFeatureClient$CDIWrapper_ClientProxy.zig:28)
    at my.feature.MyFeatureClient$CDIWrapper_Bean.proxy(FeatureServiceClient$CDIWrapper_Bean.zig:40)
    at my.feature.MyFeatureClient$CDIWrapper_Bean.get(FeatureServiceClient$CDIWrapper_Bean.zig:243)
    at my.feature.MyFeatureClient$CDIWrapper_Bean.get(FeatureServiceClient$CDIWrapper_Bean.zig:259)
    at my.consumer.Myservice_Bean.create(MyService_Bean.zig:175)
    ... 67 more
    <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
    <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
    <quarkus.platform.version>2.3.0.CR1</quarkus.platform.version>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烏雲後面有陽光 2025-01-30 17:11:41

因此,找到了解决方案。

我在模块中添加了以下构建插件,该模块


  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${compiler-plugin.version}</version>
        <configuration>
          <parameters>${maven.compiler.parameters}</parameters>
          <annotationProcessorPaths>
            <path>
              <groupId>org.projectlombok</groupId>
              <artifactId>lombok</artifactId>
              <version>${org.projectlombok.version}</version>
            </path>
          </annotationProcessorPaths>
          <!-- the parameters=true option is critical so that RESTEasy works fine -->
          <parameters>true</parameters>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jboss.jandex</groupId>
        <artifactId>jandex-maven-plugin</artifactId>
        <version>1.1.0</version>
        <executions>
          <execution>
            <id>make-index</id>
            <goals>
              <goal>jandex</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

不确定哪些导致错误解决的问题,我不会期望任何丢失的人都有这样的错误。

So, found the solution.

I added the following build plugins to the module contianing my Client interface


  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${compiler-plugin.version}</version>
        <configuration>
          <parameters>${maven.compiler.parameters}</parameters>
          <annotationProcessorPaths>
            <path>
              <groupId>org.projectlombok</groupId>
              <artifactId>lombok</artifactId>
              <version>${org.projectlombok.version}</version>
            </path>
          </annotationProcessorPaths>
          <!-- the parameters=true option is critical so that RESTEasy works fine -->
          <parameters>true</parameters>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jboss.jandex</groupId>
        <artifactId>jandex-maven-plugin</artifactId>
        <version>1.1.0</version>
        <executions>
          <execution>
            <id>make-index</id>
            <goals>
              <goal>jandex</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

not entirely sure which of those caused the error to get solved really and i wouldn't expect such an error for any of those being missing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文