md_files/项目/草稿.md

9 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

核心比较如下:
| 核心点 | Apache HttpClient | Retrofit |
| --------------- | ----------------------------------------- | ------------------------------------------------------------ |
| 编程模型 | 细粒度调用,手动构造 `HttpGet`/`HttpPost` | 注解驱动接口方法,声明式调用 |
| 请求定义 | 手动拼接 URL、参数 | 用 `@GET`/`@POST``@Path``@Query``@Body` 注解 |
| 序列化/反序列化 | 手动调用 `ObjectMapper`/`Gson` | 自动通过 `ConverterFactory`Jackson/Gson 等) |
| 同步/异步 | 以同步为主,异步需自行管理线程和回调 | 同一个 `Call<T>` 即可 `execute()`(同步)或 `enqueue()`(异步) |
| 扩展性与拦截器 | 可配置拦截器,但需手动集成 | 底层基于 OkHttp天然支持拦截器、连接池、缓存、重试和取消 |