2

I am trying to integrate a second rest client to my micro service and am getting an error.

@RegisterRestClient
public interface <my-interface> {
@POST
@Path("/example")
Response postStuff(DataBean data);
}

The injection class does it as follows:

@Inject @Any
protected <my-interface> api;

Following is the error msg:

 javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type <my-class> and qualifiers [@Any]

I have seen this issue pop up a lot but adding @ApplicationScoped or @Singleton does not work for me. As I understand the @Path annotation should make the interface discoverable. My other interface does not have any issues and I cannot imagine why.

Help is appreciated :)

helplessMax
  • 63
  • 2
  • 6

2 Answers2

2

Use the @RestClient annotation for injection:

@RestClient
protected <my-interface> api;
Tim
  • 1,315
  • 1
  • 14
  • 35
1

As Kerim said. You need to define the scope in the application.properties as described here: Using the rest client: Create the configuration (Quarkus)

Laurel
  • 5,965
  • 14
  • 31
  • 57
helplessMax
  • 63
  • 2
  • 6
  • So I just added the scope to the application.properties and I'm running into the same issue. This is only the case while compiling with quarkus:test. Protected should not be an issue bc the other API is also injected as protected. Can Quarkus only use one API per service? – helplessMax Apr 26 '22 at 12:43
  • Is there a better way to contact multiple APIs? I know I could use @Path to specify the URLs, but I need to specify the URLs in the application.properties – helplessMax Apr 26 '22 at 12:58