了解Spring @Autowired用法
我正在阅读spring 3.0.x参考文档,以了解Spring Autowired注释: 3.9.2 @Autowired和@Inject 我无法理解以下示例。我们需要在XML中做一些工作才能使其工作吗? 例子1 public class SimpleMovieLister { private MovieFinder movieFinder; @Autowired public void setMovieFinder(MovieFinder movieFinder) { this.movieFinder = movieFinder; } // ... } 实施例2 public class MovieRecommender { private MovieCatalog movieCatalog; private CustomerPreferenceDao customerPreferenceDao; @Autowired public void prepare(MovieCatalog movieCatalog, CustomerPreferenceDao customerPreferenceDao) { this.movieCatalog = movieCatalog; this.customerPreferenceDao …