Injecting Dependencies

Use @Inject to inject dependencies into fields, methods, or constructors. For example:

public class MyService {
    @Inject
    private Dependency dependency;

    @Inject
    public MyService(AnotherDependency anotherDependency) {
        // constructor code
    }
}

Last updated