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
Post a Comment