/java-skills:unirest-java-3from java-skills
Covers Unirest-Java 3.x HTTP client for Java 8+, including fluent API for GET/POST/PUT/DELETE, JSON mapping with built-in GSON, async requests, file uploads, mocking, proxy config, interceptors, and connection pool tuning.
Ships in java-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill covers the Unirest-Java 3.x HTTP client library for Java 8+. It uses Apache HttpClient 4 as the HTTP engine and includes GSON as the default JSON parser.
concurrency(total, perRoute))automaticRetries())Use this skill when the user needs to:
concurrency())Maven dependency (Unirest 3.14.5):
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.14.5</version>
</dependency>
✅ No JSON module declaration needed — GSON is included by default.
Minimal GET request:
String body = Unirest.get("https://api.example.com/users")
.asString()
.getBody();
Minimal POST with JSON:
HttpResponse<JsonNode> response = Unirest.post("https://api.example.com/users")
.header("Content-Type", "application/json")
.body(new User("Alice", "[email protected]"))
.asJson();
Unirest 3.x is a single dependency that includes GSON by default:
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.14.5</version>
</dependency>
✅ No need to declare a separate JSON module —
JsonObjectMapper(GSON-based) is included.
All configuration goes through Unirest.config():
Unirest.config()
.connectTimeout(5000)
.socketTimeout(10000)
.concurrency(200, 20)
.setDefaultHeader("Accept", "application/json")
.setDefaultBasicAuth("user", "pass")
.followRedirects(true)
.verifySsl(true)
.enableCookieManagement(true)
.automaticRetries(true)
.proxy("proxy.com", 8080, "user", "pass");
Key config options:
| Method | Impact | Default |
|---|---|---|
connectTimeout(int) | Connection timeout (ms) | 10000 |
socketTimeout(int) | Socket/read timeout (ms) | 60000 |
concurrency(int, int) | Max total connections, max per route | 200/20 |
followRedirects(boolean) | Follow HTTP redirects | true |
verifySsl(boolean) | Enforce SSL verification | true |
enableCookieManagement(boolean) | Accept/store cookies | true |
automaticRetries(boolean) | Auto-retry on socket errors (up to 4 times) | true |
retryAfter(boolean) | Auto-retry on 429/529 with Retry-After header | false |
defaultBaseUrl(String) | Default base URL for all requests | none |
addShutdownHook(boolean) | Register JVM shutdown hook | false |
useSystemProperties(boolean) | Use system properties for proxies etc. | true |
Multiple configurations:
// Primary instance (same as static Unirest)
UnirestInstance unirest = Unirest.primaryInstance();
// Spawn a new independent instance
UnirestInstance custom = Unirest.spawnInstance();
custom.config().connectTimeout(3000);
⚠️ If you spawn a new instance, YOU are responsible for shutting it down.
See references/configuration.md for full config table, interceptors, object mappers, and metrics.
Basic request types:
Unirest.get("http://localhost/users").asString();
Unirest.post("http://localhost/users").body(json).asJson();
Unirest.put("http://localhost/users/1").body(user).asEmpty();
Unirest.delete("http://localhost/users/1").asEmpty();
Route parameters:
Unirest.get("http://localhost/users/{id}")
.routeParam("id", "42")
.asString();
// Results in http://localhost/users/42
Query parameters:
Unirest.get("http://localhost/search")
.queryString("q", "unirest")
.queryString("page", 1)
.asString();
Headers and auth:
Unirest.get("http://localhost/protected")
.header("X-Custom", "value")
.basicAuth("user", "pass")
.asString();
Form data:
Unirest.post("http://localhost/form")
.field("name", "Alice")
.field("age", 30)
.asEmpty();
File upload:
Unirest.post("http://localhost/upload")
.field("file", new File("/path/to/file.zip"))
.asEmpty();
Async request:
CompletableFuture<HttpResponse<JsonNode>> future = Unirest.get("http://localhost/data")
.asJsonAsync(response -> {
System.out.println(response.getBody());
});
Per-request proxy (3.x only):
Unirest.get("http://localhost/data")
.proxy("proxy.com", 8080)
.asString();
JSON Patch (RFC-6902):
Unirest.jsonPatch("http://localhost/resource")
.add("/fruits/-", "Apple")
.remove("/bugs")
.replace("/name", "Updated")
.asJson();
See references/requests.md for upload progress, paged requests, client certificates, and more.
Response types:
// String
String body = Unirest.get(url).asString().getBody();
// Object mapping (GSON included by default)
Book book = Unirest.get(url).asObject(Book.class).getBody();
// Generic types
List<Book> books = Unirest.get(url)
.asObject(new GenericType<List<Book>>(){}).getBody();
// JSON
JsonNode json = Unirest.get(url).asJson().getBody();
// File
File file = Unirest.get(url).asFile("/tmp/download.zip").getBody();
// Empty (status/headers only)
HttpResponse resp = Unirest.delete(url).asEmpty();
Error handling:
Unirest.get("http://localhost/data")
.asJson()
.ifSuccess(response -> handleSuccess(response))
.ifFailure(response -> {
log.error("Status: " + response.getStatus());
response.getParsingError().ifPresent(e -> {
log.error("Parse error: " + e.getMessage());
});
});
Parsing errors:
response.getParsingError().ifPresent(ex -> {
String originalBody = ex.getOriginalBody();
String message = ex.getMessage();
});
Map error objects:
HttpResponse<Book> book = Unirest.get(url).asObject(Book.class);
Error err = book.mapError(Error.class);
See references/responses.md for download progress, large responses, body mapping, and more.
Static mock:
MockClient mock = MockClient.register();
mock.expect(HttpMethod.GET, "http://api.example.com/users")
.thenReturn("{\"name\":\"Alice\"}")
.withStatus(200);
String body = Unirest.get("http://api.example.com/users")
.asString().getBody();
// body == "{\"name\":\"Alice\"}"
mock.verifyAll(); // Verify all expects were called
Instance mock (3.x requires both clients):
UnirestInstance unirest = Unirest.spawnInstance();
MockClient mock = MockClient.register(unirest);
// In 3.x, the mock implements both Client and AsyncClient
Body matching:
mock.expect(HttpMethod.POST, "http://api.example.com/users")
.body(FieldMatcher.of("name", "Alice", "role", "admin"))
.thenReturn()
.withStatus(201);
Verify with times:
var expect = mock.expect(HttpMethod.GET, "http://api.example.com/users").thenReturn();
expect.verify(); // At least once
expect.verify(Times.never()); // Never called
See references/mocking.md for POJO responses, multiple expects, and more.
Basic caching:
Unirest.config().cacheResponses(true);
Advanced caching with options:
Unirest.config().cacheResponses(Cache.builder()
.depth(100) // Max entries
.maxAge(5, TimeUnit.MINUTES)); // Entry TTL
Custom cache (e.g., Guava):
Unirest.config().cacheResponses(
Cache.builder().backingCache(new MyGuavaCache()));
See references/caching.md for custom cache implementation details.
Simple proxy:
Unirest.config().proxy("proxy.com", 8080, "user", "pass");
Per-request proxy (3.x only):
Unirest.get("http://localhost/data")
.proxy("proxy.com", 8080)
.asString();
System properties (default: true in 3.x):
System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "7777");
// useSystemProperties defaults to true in 3.x
See references/proxies.md for details.
| Error | Cause | Fix |
|---|---|---|
NoClassDefFoundError: kong/unirest/Unirest | Wrong package | Use import kong.unirest.* (not kong.unirest.core.*) |
asObject() returns null body | Response parsing failed | Check response.getParsingError() for details |
ConnectException: Connection timed out | Server unreachable or timeout too low | Increase connectTimeout or check network |
SocketTimeoutException | Read timeout exceeded | Increase socketTimeout (default 60000ms) |
SSLHandshakeException | SSL verification failure | Use verifySsl(false) for dev only, fix certs in prod |
| Proxy not working | System props may be disabled | Check useSystemProperties(true) (default true in 3.x) |
| Too many connections | Connection pool exhausted | Increase concurrency(total, perRoute) |
| Automatic retries not working | Disabled or not applicable | Check automaticRetries(true) (default true) |
kong.unirest — Not kong.unirest.core (that's 4.x)unirest-java:3.14.5 (unlike 4.x which uses BOM + core + module)socketTimeout() controls read timeout separately from connectTimeout()concurrency(total, perRoute) lets you tune Apache's connection poolautomaticRetries(true) retries socket errors up to 4 timesrequest.proxy(host, port) works (removed in 4.x)hostnameVerifier(verifier) for custom SSL hostname verificationaddShutdownHook(true) registers JVM shutdown hooksuseSystemProperties defaults to true (unlike 4.x)Unirest.sse() does not exist in 3.xClient and AsyncClientagents/openai.yaml (opens in a new tab)references/caching.md (opens in a new tab)references/configuration.md (opens in a new tab)references/mocking.md (opens in a new tab)references/proxies.md (opens in a new tab)references/requests.md (opens in a new tab)references/responses.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
Generated from the plugin's indexed repository (full-stack-skills/java-skills) — no native marketplace selected
npx claudepluginhub p/full-statck-skills-java-skills39 skills in this plugin
/caffeine-patternsCaffeine JVM 本地缓存技能。覆盖本地缓存 vs 远程缓存(Redis)选择决策树、expireAfterWrite vs expireAfterAccess vs refreshAfterWrite 三种过期策略对比与组合规则(refresh < expire)、CacheLoader加载与reload异步刷新模式、Spring Cache @Cacheable集成、maximumSize驱逐策略、recordStats缓存统计。 纠正 LLM:用 ConcurrentHashMap+手动过期、所有缓存走Redis、refreshAfterWrite > expireAfterWrite导致永远不刷新、CacheLoader返回null导致缓存穿透。/commons-patternsApache Commons 最佳实践模式。从官方文档提炼,覆盖 Commons Lang3(StringUtils千面判空/isEmpty vs isBlank/Validate抛NullPointerException迁移)、Commons IO(IOUtils.toString大文件陷阱/FileUtils.lineIterator逐行读模式/FilenameUtils.normalize路径规范化)、Commons Collections4(CollectionUtils.union/intersection/subtract集合运算)。 纠正 LLM 误用:混淆 StringUtils.isBlank vs isEmpty、IOUtils.toString 读大文件OOM、不知道 LineIterator 逐行读模式、用 lang 而非 lang3 包名。/easy4j-deployeasy4j 组织标准发布流程与多分支 Maven 发布规范。适用于 io.github.easy4j 仓库(如 openclaw-java-sdk、okhttp3-extension 及其他 easy-4-java 组织组件)的以下场景:(1) SDK 三分支正式版发布(标准流程:创建 tag → 发布 Maven Central → bump SNAPSHOT,支持子智能体并行编排),(1b) xxx-spring-boot-starter 十分支发布(依赖 SDK 先转正式版 + tag + Central + bump),(2) 发布阿里云私有库 SNAPSHOT,(3) 三分支(feature/1.0.x JDK 8、feature/2.0.x JDK 17、feature/3.0.x JDK 21)源码同步,(4) 发布前 CVE 扫描与依赖升级(Jackson BOM 版本控制规则、JDK 依赖天花板),(5) 发布故障排查(409 冲突、Central 拒绝 SNAPSHOT 依赖、argLine 问题)。触发词:发布、上线、deploy、release、发版、发布正式版、同步分支、版本号升级。/easyexcel-fill基于 Alibaba EasyExcel(com.alibaba:easyexcel:4.0.3)的 Excel 模板填充技能。覆盖简单对象填充、列表填充({.}+forceNewRow)、横向多列组合填充(FillWrapper+WriteDirectionEnum.HORIZONTAL)、复杂填充(含合计行/统计行/先 fill 后 write)、Spring Boot 集成、模板设计规范、转义字符、03版/07版差异、性能优化(分次 fill、文件缓存)。当用户需要把 Java 对象或 Map 数据按预制 .xlsx 模板(变量语法 {var}、{.}、{prefix.})填充生成报表(工资条/合同/对账单/发票/财务报表/统计表/汇总表)时使用此技能,不适用于不基于模板的"程序生成 Excel"场景(改用 easyexcel-write)。/easyexcel-read基于 Alibaba EasyExcel(com.alibaba:easyexcel:4.0.3)的 Excel 数据读取技能。覆盖监听器模式(ReadListener/AnalysisEventListener/PageReadListener)、同步读取(doReadSync)、多 Sheet 读取、@ExcelProperty(index/name)匹配、多行表头(headRowNumber)、日期数字自定义转换器(@DateTimeFormat/@NumberFormat/Converter)、监听器异常处理(onException + ExcelDataConvertException)、额外信息读取(批注/超链接/合并单元格,extraRead + CellExtra)、公式和单元格类型(CellData<T>)、不创建对象的读(ReadListener<Map<Integer,String>>)、Web 上传读取(MultipartFile→InputStream)。当用户需要解析 Excel(导入数据/批量入库/对账文件/用户上传/Excel 转对象/Excel 转 Map)时使用此技能,不适用于按预制模板填充(改用 easyexcel-fill)、不适用于程序化生成 Excel(改用 easyexcel-write)。/easyexcel-write基于 Alibaba EasyExcel(com.alibaba:easyexcel:4.0.3)的 Excel 数据写入技能。覆盖最简写入(3 种写法)、复杂表头(多级)、@ExcelProperty/@ExcelIgnore/@DateTimeFormat/@NumberFormat 注解、includeColumn/excludeColumn 选择列、@ColumnWidth/@ContentRowHeight 样式注解、@HeadStyle/@ContentStyle 自定义样式、合并单元格(@ContentLoopMerge/LoopMergeStrategy)、图片导出(File/InputStream/URL/byte[])、超链接/批注/公式/富文本(WriteCellData)、动态表头、自动列宽、自定义拦截器(CellWriteHandler/SheetWriteHandler/RowWriteHandler)、分页分批写入、Web 下载直接写 OutputStream、03/07 版兼容。当用户需要程序化生成 Excel(无预制模板)导出订单/用户/财务/库存/报表/对账单/审批单等结构化数据时使用此技能,不适用于按预制模板填充(改用 easyexcel-fill)、不适用于读取 Excel(改用 easyexcel-read)。