依賴注入是否意味着你不需要'new'關鍵字?或者是否有理由直接創建簡單的葉類,如集合?在使用依賴注入時,有沒有'新'的情況?
在下面我的例子中注入比較,查詢和DAO,但SortedSet的直接實例:
public Iterable<Employee> getRecentHires()
{
SortedSet<Employee> entries = new TreeSet<Employee>(comparator);
entries.addAll(employeeDao.findAll(query));
return entries;
}
Spring還擁有用於私有成員操作的`ReflectionTestUtils`類。 – 2013-05-21 09:19:23