利用feign调用远程服务的时候,自动把服务地址中IP跟端口中间的冒号转码,引发未知host异常

代码如下
1、声明的伪客户端
@FeignClient(name = "health-http", url = "http://";)
public interface HealthService {

    @RequestMapping(value = "{addresss}/health", method = RequestMethod.GET)
    public String getHealthInfo(@PathVariable("addresss") String address);
}
 
2、调用
@Autowired
 private HealthService healthService;
 
String info = healthService.getHealthInfo(“10.143.128.215:17001”);
 
异常
Caused by: java.net.UnknownHostException: 10.143.128.215%3A17001
 
 
如何规避这个问题,另外自定义Encode配置好像不生效
已邀请:

vincent

赞同来自:

FeignClient不是你这样使用的,你把ip:port写到@FeignClient的url中。FeignClient对url的定义就是(An absolute URL or resolvable hostname (the protocol is optional)

要回复问题请先登录注册