简体   繁体   English

RestTemplate getForEntity方法未定义

[英]RestTemplate getForEntity method undefined

I am trying to build a project in Eclipse Luna and encounter an error on several lines in the Test class that reference getForEntity, eg: 我正在尝试在Eclipse Luna中构建项目,并且在引用getForEntity的Test类的几行上遇到错误,例如:

verify(mockRestTemplate,times(1)).getForEntity(any(), eq(String.class));

mockRestTemplate is defined as a variable of class RestTemplate, and I have imported: mockRestTemplate被定义为RestTemplate类的变量,并且我已经导入:

import org.springframework.web.client.RestTemplate;

I get the error in Eclipse: 我在Eclipse中收到错误:

The method getForEntity(Object, Class) is undefined for the type RestTemplate 对于类型RestTemplate,未定义方法getForEntity(Object,Class)

This code does not cause an error for colleagues using the same project, so I suspect it is something local to my environment. 这段代码不会对使用同一项目的同事造成错误,因此我怀疑这是我的环境本地的。

Many thanks, Keith. 非常感谢,基思。

You should provide explicit argument type rather than use any() . 您应该提供显式参数类型,而不要使用any() Try to change the code depending on the actual expectation. 尝试根据实际期望更改代码。

verify(mockRestTemplate,times(1)).getForEntity(any(String.class), eq(String.class));

verify(mockRestTemplate,times(1)).getForEntity(any(URI.class), eq(String.class));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM