Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot resolve method 'create' in 'RequestBody' #37

Closed
woow-wu7 opened this issue Feb 12, 2021 · 4 comments
Closed

Cannot resolve method 'create' in 'RequestBody' #37

woow-wu7 opened this issue Feb 12, 2021 · 4 comments

Comments

@woow-wu7
Copy link

RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(accessTokenDTO));
Request request = new Request.Builder()
.url("https://github.com/login/oauth/access_token")
.post((okhttp3.RequestBody) body)
.build();

create方法报错,如何解决啊?卡在这里了

@woow-wu7
Copy link
Author

求解决

@woow-wu7
Copy link
Author

有人帮忙解决下嘛

@woow-wu7
Copy link
Author

已解决,知悉看了引入的依赖,发现RequestBody引错了

@woow-wu7
Copy link
Author

woow-wu7 commented Feb 12, 2021

package com.example.demo.provider;

import com.alibaba.fastjson.JSON;
import com.example.demo.dto.AccessTokenDTO;
import com.example.demo.dto.GitHubUserDTO;
import okhttp3.*;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

import java.io.IOException;

删掉import org.springframework.web.bind.annotation.RequestBody;

归总:
// import org.springframework.web.bind.annotation.RequestBody;
// 上面这个引入RequestBody是巨坑,https://blog.csdn.net/qy_0626/article/details/107716733
// 别引入错了,所以说自动引入有时候在不熟悉java时,有点难搞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant