spring-boot - 调用 REST API 时 GCP 中的异常
问题描述
我是 GCP 的新手,并部署了一个带有 mysql db 连接的示例 spring boot 应用程序。在调用休息 API 时遇到异常。相同的原因可能是什么。
2021-06-26T05:56:35.029691281Zcom.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
Info
2021-06-26T05:56:35.029699031Z{
Info
2021-06-26T05:56:35.029705107Z "code" : 403,
Info
2021-06-26T05:56:35.029711431Z "errors" : [ {
2021-06-26T05:56:35.029717697Z "domain" : "global",
Info
2021-06-26T05:56:35.029723141Z "message" : "Insufficient Permission",
Info
2021-06-26T05:56:35.029729203Z "reason" : "insufficientPermissions"
Info
2021-06-26T05:56:35.029735192Z } ],
Info
2021-06-26T05:56:35.029741632Z "message" : "Request had insufficient authentication scopes.",
Info
2021-06-26T05:56:35.029747360Z "status" : "PERMISSION_DENIED"
Info
2021-06-26T05:56:35.029753095Z}
以下端点工作正常
@SpringBootApplication
public class EmployeeJdbcApplication {
@RequestMapping("/")
String home() {
return "This is sample jdbc mysql connection app.....";
}
public static void main(String[] args) {
SpringApplication.run(EmployeeJdbcApplication.class, args);
}
}
获取以下端点的异常
@RestController
public class EmployeeController {
@Autowired
EmployeeService empService;
@RequestMapping(value = "/employees", method = RequestMethod.GET)
public List<Employee> getEmployees() {
return empService.getAllEmployees();
}
@RequestMapping(value = "/insertemployee", method = RequestMethod.POST)
public void insertEmployee(@RequestBody Employee employee) {
empService.insertEmployee(employee);
}
}
解决方案
推荐阅读
- angular - 尝试设置笑话的问题:应用程序代码编译得很好,但测试代码没有
- css - 悬停元素内的CSS更改类
- android - Android - 在通知上单击打开文件并按回不显示应用程序
- python - Altair 图表图例中的元素数量
- angular - Angular 编译之间的差异
- r - 创建一个循环函数结果的数据框
- json - TypeError: JSON.stringify(...).then 不是函数
- mysql - 用 union 改变结果的mysql顺序
- list - 具有小二进制占用空间(千字节)的虚拟机/编程语言
- javascript - Videojs 有时不会发生并在我的 Reactjs 项目中出错