Spring - Dependency Injection with @Inject

@Inject


Instead of @Autowired, you can use @javax.inject.Inject as follows:

import javax.inject.Inject;

public class SimpleTestInject {

    private MovieFinder movieFinder;

    @Inject
    public void setMovieFinder(MovieFinder movieFinder) {
        this.movieFinder = movieFinder;
    }

    public void listMovies() {
        this.movieFinder.findMovies(...);
        // ...
    }
}

with @Autowired, you can use @Inject at the field level, method level and constructor-argument level.

Comments

Popular posts from this blog

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept