【发布时间】:2015-02-12 09:37:43
【问题描述】:
我刚迁移到 Java 8,遇到了一些我不知道如何克服的编译错误。
以下代码无法编译:
Mockito.when(
jdbcTemplate.query(Mockito.eq(expectedQuery1),
Mockito.any(ResultSetExtractor.class))).thenReturn(mockReturn1);
有错误:
The method query(String, ResultSetExtractor<T>) in the type JdbcTemplate is not
applicable for the arguments (String, ResultSetExtractor)
我尝试了Java 1.8 with Mockito 1.9.5 gives compile errors的另一种方法:
Mockito.when(jdbcTemplate.query(Mockito.eq(expectedQuery1), Mockito.any()))
.thenReturn(mockReturn1);
现在我收到以下错误:
The method when(T) in the type Mockito is not applicable for the arguments (void)
这究竟应该如何工作,为什么一开始就不能工作
【问题讨论】: