Tag: netflix feign

不能在spring boot quartz中使用autowired feign client

我正在使用Netflix-OSS的 Spring启动它是一个很好的微服务系统,工作正常,我正在使用Feign Client ,以便在服务和Quartz之间建立连接以运行后台作业。 但是当我在工作中使用Autowired feign-client时会出现问题。 @FeignClient(value = “user”, configuration = {OAuthFeignConfig.class}, fallback = UserClientFallback.class) public interface UserClient { @RequestMapping(value = “/api/user/get/userName/{userName}”, method = RequestMethod.GET) UserInfoResponse getUserInfoByUserName(@PathVariable(“userName”) String userName); 和石英代码: public class DoJob extends RunnableTask { @Autowired private UserClient userClient; @Override public int run(JobExecutionContext jobExecutionContext) { userInfoById = userClient.getUserInfoById(“123e4567-e89b-12d3-a456-426655440000”); return userinfo.getIntId(); } } 和例外是: Error […]

Netflix Feign – 通过微服务传播状态和exception

我正在使用Netflix Feign将微服务A的一个操作调用到微服务B的其他操作,该操作使用Spring Bootvalidation代码。 如果validation不好,微服务B的操作会抛出exception。 然后我在微服务中处理并返回一个HttpStatus.UNPROCESSABLE_ENTITY (422),如下所示: @ExceptionHandler({ ValidateException.class }) @ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) @ResponseBody public Object validationException(final HttpServletRequest request, final validateException exception) { log.error(exception.getMessage(), exception); error.setErrorMessage(exception.getMessage()); error.setErrorCode(exception.getCode().toString()); return error; } 因此,当微服务A在接口中调用B作为下一个: @Headers(“Content-Type: ” + MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestLine(“GET /other”) void otherOperation(@Param(“other”) String other ); @Headers(“Content-Type: ” + MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestLine(“GET /code/validate”) Boolean validate(@Param(“prefix”) String prefix); static PromotionClient connect() { return Feign.builder() […]

使用Feign文件上传 – multipart / form-data

我正在尝试使用feign完成多部分文件上传,但我似乎无法在任何地方找到它的好例子。 我基本上希望HTTP请求与此类似: … Content-Type: multipart/form-data; boundary=AaB03x –AaB03x Content-Disposition: form-data; name=”name” Larry –AaB03x Content-Disposition: form-data; name=”file”; filename=”file1.txt” Content-Type: text/plain … contents of file1.txt … –AaB03x– 甚至… ——fGsKo01aQ1qXn2C Content-Disposition: form-data; name=”file”; filename=”file.doc” Content-Type: application/octet-stream … binary data … ——fGsKo01aQ1qXn2C– 我是否需要手动构建请求主体,包括生成多部分边界? 考虑到这个客户端可以做的其他事情,这似乎有点过分了。

从另一个项目注入FeignClient时出错

我无法从另一个项目自动连接假装客户端。 似乎没有生成和注入假装客户端的实现。 这是我得到的错误。 org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘passportRestController’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wstrater.service.contacts.client.ContactService com.wstrater.service.passport.server.controllers.PassportRestController.contactService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.wstrater.service.contacts.client.ContactService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} […]