Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
maxandersen opened this issue Apr 1, 2024 · 0 comments
Open

Comments

@maxandersen
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant