不兼容的类型错误将在升级为5.3.20之后显示
全部, 我有一个Junits的Maven Java项目: 例如:
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import com.jayway.jsonassert.impl.matcher.IsCollectionWithSize;
@Test
public void test() throws Exception {
getMockMvc().perform(put("/bla")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON_VALUE)
.characterEncoding("UTF-8")
.content("{\n" +
"\n" +
"\"eventTypes\": [\"BLA\"]\n" +
"\n" +
"}"))
.andExpect(jsonPath("$.eventTypes", IsCollectionWithSize.hasSize(1)));
}
运行检查的行: JSONPATH(“ $。EventTypes”,IscollectionWithSize.Hassize(1)
JSONPATH是Spring Libary Verion 4.3.30的一部分 isCollectionWithSize.hassize是com.jayway.jsonpath.json-path-assert verion 2.4
一切正常的,直到我将春季升级到5.3.20,一切正常 错误是:
incompatible types: cannot infer type-variable(s) T,capture#79 of ? super java.util.Collection<? extends E>,E
[ERROR] (argument mismatch; org.hamcrest.Matcher<capture#80 of ? super java.util.Collection<? extends E>> cannot be converted to org.hamcrest.Matcher<? super java.lang.Object>)
[ERROR] -> [Help 1]
有人有这样的问题吗?可以提供解决方案吗?
all,
I have a maven java project with junits:
for example:
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import com.jayway.jsonassert.impl.matcher.IsCollectionWithSize;
@Test
public void test() throws Exception {
getMockMvc().perform(put("/bla")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON_VALUE)
.characterEncoding("UTF-8")
.content("{\n" +
"\n" +
"\"eventTypes\": [\"BLA\"]\n" +
"\n" +
"}"))
.andExpect(jsonPath("$.eventTypes", IsCollectionWithSize.hasSize(1)));
}
the line that run the check:
jsonPath("$.eventTypes", IsCollectionWithSize.hasSize(1)
the jsonPath is part of Spring libary verion 4.3.30
and the IsCollectionWithSize.hasSize is taken form com.jayway.jsonpath.json-path-assert verion 2.4
everything worked ok until I upgraded the Spring to 5.3.20
The error is:
incompatible types: cannot infer type-variable(s) T,capture#79 of ? super java.util.Collection<? extends E>,E
[ERROR] (argument mismatch; org.hamcrest.Matcher<capture#80 of ? super java.util.Collection<? extends E>> cannot be converted to org.hamcrest.Matcher<? super java.lang.Object>)
[ERROR] -> [Help 1]
Has anyone had such a problem? And can offer a solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我通过更改其中一个进口来修复它。
而不是这样:
我使用了以下方式:
并从中更改代码:
对此:
ok so I fixed it by changing one of the imports.
instead of this:
I used this:
and change the code from this:
to this: