依赖注入是否意味着你不需要'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