gpt4 book ai didi

java - Spring Boot 假装异常

转载 作者:行者123 更新时间:2023-12-02 10:18:38 25 4
gpt4 key购买 nike

我正在尝试使用 application/x-www-form-urlencoded 发出 API 请求。

这是我的假客户:

 @Bean
public YandexDelivery yandexDelivery() {
return Feign.builder()
.client(new OkHttpClient())
.encoder(new FormEncoder())
.decoder(new GsonDecoder())
.logger(new Slf4jLogger(YandexDelivery.class))
.logLevel(Logger.Level.FULL)
.target(YandexDelivery.class, "https://delivery.yandex.ru/api/last/searchDeliveryList");

}

这是我的界面:

public interface YandexDelivery {
@RequestLine("POST")
@Headers({"Content-Type: application/x-www-form-urlencoded"})
Delivery getDeliveryVariants(Map<String, ?> request);

}

这就是我的调用方式:

@Autowired
private YandexDelivery yandexDelivery;

@Override
public Delivery getDeliverysType(String cityFrom, String cityTo, Integer clientId, String deliveryType, Integer height, Integer indexCity, Integer length, Integer senderId, Integer weight, Integer width) {
DeliveryVariantsModel model = new DeliveryVariantsModel(cityFrom, cityTo, clientId, deliveryType, height, indexCity, length, senderId, weight, width);
HashMap<String, String> map = new HashMap<>();
map.put("secret_key", model.getSecretKey());
map.put("client_id", model.getClientId().toString());
map.put("sender_id", model.getSenderId().toString());
map.put("city_from", model.getCityFrom());
map.put("city_to", model.getCityTo());
map.put("weight", model.getWeight().toString());
map.put("length", model.getLength().toString());
map.put("width", model.getWidth().toString());
map.put("height", model.getHeight().toString());
map.put("delivery_type", model.getDeliveryType());
map.put("index_city", model.getIndexCity().toString());
return yandexDelivery.getDeliveryVariants(map);
}

这是我的错误:

java.lang.ClassNotFoundException: feign.Request$Body

最佳答案

您是否遗漏了依赖项中的spring-cloud-starter-feign

关于java - Spring Boot 假装异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54494956/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com