英文:
feign client internal server exception (rest template didnt work either)
问题
上次我发布时出现了访问令牌错误。我还尝试过使用RestTemplate,但仍然出现相同的错误。
"timestamp": 1597323995055,
"status": 500,
"error": "Internal Server Error",
"message": "请求访问令牌时出错。",
"path": "/api/dashboard"
}
我的代码如下:
Controller.class
@RestController
@RequestMapping("/api/dashboard")
@AllArgsConstructor
public class LexcorpIntegrationController {
private final TestServicee testServicee;
@GetMapping
public List<IncidentTasksResponse> getIT() {
return testServicee.getFeign();
}
}
这是Service.class
@Service
@AllArgsConstructor
public class TestServicee {
private final LexcorpProxy proxy;
private final RestTemplate restTemplate;
public List<IncidentTasksResponse> getIT() {
DateFilter dto = new DateFilter();
dto.setDate(null);
WrapperEntity wrapperEntity =
restTemplate.getForObject(
"http://im-sure-url-is-correct",
WrapperEntity.class,
dto);
List<IncidentTasksResponse> tasks = wrapperEntity.getList();
return tasks;
}
public List<IncidentTasksResponse> getFeign() {
DateFilter filter = new DateFilter();
filter.setDate(null);
return proxy.getAllIncidentTasks(filter);
}
}
Client.interface
@Component
@FeignClient(name = "lexcorp", url = "url-is-correct")
public interface LexcorpProxy {
@PostMapping("/IncidentTasks")
List<IncidentTasksResponse> getAllIncidentTasks(DateFilter date);
}
我想说的第一件事是,我使用第三方VPN来访问数据。但我写的另一段代码(2)可以正常工作,所以这不是问题所在。
1- 这是Spring Cloud,所以它从另一个微服务获取依赖项等。后来,我无论如何都在pom.xml中添加了依赖项。仍然没有起作用。
2- 尝试在我的本地创建一个简单的Feign应用程序(另一个应用程序也在我的本地)。它可以工作,我可以从API获取数据。
3- 我在客户端方法内部写的参数是正确的。
对所有答案表示感谢。我是否遗漏了什么?即使有一点解释也会帮助我。
英文:
The last time i've posted i got an accessing token error. I also tried with rest template ; still the same error.
"timestamp": 1597323995055,
"status": 500,
"error": "Internal Server Error",
"message": "Error requesting access token.",
"path": "/api/dashboard"
}
My code looks like this;
Controller.class
@RestController
@RequestMapping("/api/dashboard")
@AllArgsConstructor
public class LexcorpIntegrationController {
private final TestServicee testServicee;
@GetMapping
public List<IncidentTasksResponse> getIT() {
return testServicee.getFeign();
}
/*
This is Service.class
@Service
@AllArgsConstructor
public class TestServicee {
private final LexcorpProxy proxy;
private final RestTemplate restTemplate;
public List<IncidentTasksResponse> getIT() {
DateFilter dto = new DateFilter();
dto.setDate(null);
WrapperEntity wrapperEntity =
restTemplate.getForObject(
"http://im-sure-url-is-correct",
WrapperEntity.class,
dto);
List<IncidentTasksResponse> tasks = wrapperEntity.getList();
return tasks;
}
public List<IncidentTasksResponse> getFeign() {
DateFilter filter = new DateFilter();
filter.setDate(null);
return proxy.getAllIncidentTasks(filter);
}
}
Client.interface
@Component
@FeignClient(name = "lexcorp", url = "url-is-correct")
public interface LexcorpProxy {
@PostMapping("/IncidentTasks")
List<IncidentTasksResponse> getAllIncidentTasks(DateFilter date);
}
The first thing i wanna say is ; i use a 3rdPartyVpn to access data. But another code that i wrote (2)
worked so , thats not the case here.
1- This is Spring Cloud, so it gets dependencies from another microservice etc. Later , i added dependencies in pom.xml anyways.Still didnt work.
2- Try to create simple feign application in my local. (other one is also in my local anyways) It worked. I can get data from the api.
3- The parameter that i wrote inside the client method is correct.
All answers will be appreciated. Am i missing something? Even a lil explanation would help me.
答案1
得分: 0
我尝试了一切,但没有解决问题。我使用了我的其他应用程序。
英文:
I tried everything and didnt solve the problem. I used my other application instead.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论