无法解析方法' setBasicauth'在' httpheaders'
我的代码无法在“ httpheaders”中解析方法“ setBasicicAuth”。我正在尝试将我的Java代码复制到Android Studio,但面临此问题。我错过了一些进口吗?
import org.springframework.http.*;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); // works
headers.setContentType(MediaType.APPLICATION_JSON); // works
headers.setBasicAuth(this.authenticationToken); // does not work
gradle
// Spring Framework
implementation 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
My code cannot resolve method 'setBasicAuth' in 'HttpHeaders'. I am trying to copy my java code to android studio, but facing this issue. Am I missing some imports?
import org.springframework.http.*;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); // works
headers.setContentType(MediaType.APPLICATION_JSON); // works
headers.setBasicAuth(this.authenticationToken); // does not work
gradle
// Spring Framework
implementation 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论