百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

RetrofitUrlManager

> 编程语言
开源

Let Retrofit support multiple baseUrl and can be change the baseUrl at runtime (以最简洁的 Api 让 Retrofit 同时支持多个 BaseUrl 以及动态改变 BaseUrl).

2.2K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Let Retrofit support multiple baseUrl and can be change the baseUrl at runtime (以最简洁的 Api 让 Retrofit 同时支持多个 BaseUrl 以及动态改变 BaseUrl).

重新配置 URL 管理器

让 Retrofit 支持多个 baseUrl,并且可以在运行时更改 baseUrl。

概述

通知

下载

gradle
 implementation 'me.jessyan:retrofit-url-manager:1.4.0'

使用方法

初始化

java
 // When building OkHttpClient, the OkHttpClient.Builder() is passed to the with() method to initialize the configuration
 OkHttpClient = RetrofitUrlManager.getInstance().with(new OkHttpClient.Builder())
                .build();

步骤 1

java
 public interface ApiService {
     @Headers({"Domain-Name: douban"}) // Add the Domain-Name header
     @GET("/v2/book/{id}")
     Observable<ResponseBody> getBook(@Path("id") int id);
}

步骤 2

java
 // You can change BaseUrl at any time while App is running (The interface that declared the Domain-Name header)
 RetrofitUrlManager.getInstance().putDomain("douban", "https://api.douban.com");

如果您要更改全局 BaseUrl:

java
 // BaseUrl configured in the Domain-Name header will override BaseUrl in the global setting
 RetrofitUrlManager.getInstance().setGlobalDomain("your BaseUrl");

关于我

  • 电子邮件: [email protected]
  • 主页: http://jessyan.me>
  • 掘金: https://juejin.im/user/57a9dbd9165abd0061714613>
  • 简书: https://www.jianshu.com/u/1d0c0bc634db>

许可证

Copyright 2017, jessyan
根据 Apache 许可证第 2.0 版 (以下简称"许可证") 许可
除符合许可条款外,您不得使用此文件。

[  ](https://bintray.com/jessyancoding/maven/retrofit-url-manager/1.4.0/link)
[  ](https://travis-ci.org/JessYanCoding/RetrofitUrlManager)
[  ](https://android-arsenal.com/details/1/6007)
[  ](https://developer.android.com/about/versions/android-2.3.html)
[  ](http://www.apache.org/licenses/LICENSE-2.0)
[  ](https://www.jianshu.com/u/1d0c0bc634db)
[  ](https://shang.qq.com/wpa/qunwpa?idkey=7e59e59145e6c7c68932ace10f52790636451f01d1ecadb6a652b1df234df753)
[中文说明](README-zh.md)
[**Framework analysis 1**](http://www.jianshu.com/p/2919bdb8d09a)
[**Framework analysis 2**](https://www.jianshu.com/p/35a8959c2f86)
[**More complete sample**](https://github.com/JessYanCoding/ArmsComponent)

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaarmsbaseurlbaseurl-domainmvparms

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言