Feign自动拼接请求的URL
@FeignClient("user-service")
public interface UserFeignClient {
@GetMapping(value="/user/{id}",headers={"Authorization=qwer"})
User queryUserById(@PathVariable("id") Long id);
}
@Service
public class UserService {
@Autowired
private UserFeignClient userFeignClient;
public List<User> queryUserByIds(List<Long> ids) {
List<User> users = new ArrayList<>();
ids.forEach(id -> {
users.add(this.userFeignClient.queryUserById(id));
});
return users;
}
}