Skip to content

inject/restclient not needed for constructor injection in quarkus #708

Open
@maxandersen

Description

I get The Rest Client object should have the @Inject and @RestClient annotations to be injected as a CDI bean.microprofile-restclient(InjectAndRestClientAnnotationMissing) with this code for the api code which works fine in Quarkus:

@ApplicationScoped
public class AppHAContext implements IHAContext {

    private HomeAssistantAPI api;
    private HomeAssistantWS ws;

    public AppHAContext(@RestClient HomeAssistantAPI api, HomeAssistantWS ws) {
        this.api = api;
        this.ws = ws;
    }

    @Override
    public HomeAssistantAPI getApi() {
        return api;
    }

    public HomeAssistantWS ws() {
        return ws;
    }
}

quarkus does automatic constructor injection thus @Inject is not required.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions