/java-skills:jackson-patternsfrom java-skills
Guides Jackson JSON serialization with Chinese date formats (yyyy-MM-dd HH:mm:ss), null handling rules, @JsonView, ObjectMapper singleton, TypeReference generics, and Spring Boot integration.
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.
编码 Jackson 的使用规则。LLM 默认配置 SerializationFeature.WRITE_DATES_AS_TIMESTAMPS=true,但中国开发者期望 yyyy-MM-dd HH:mm:ss。
| # | 错误 | 正确做法 |
|---|---|---|
| 1 | 日期序列化为时间戳 1702468800000 | 配置 WRITE_DATES_AS_TIMESTAMPS=false,格式 yyyy-MM-dd HH:mm:ss |
| 2 | null 字段不返回或返回 null | 明确规则:数组→[]、字符串→""、数字→null、布尔→null |
| 3 | 每次 new ObjectMapper() | ObjectMapper 是线程安全的,应用级单例 |
| 4 | objectMapper.readValue(json, List.class) | objectMapper.readValue(json, new TypeReference<List<User>>(){}) |
| 5 | 标准JSON格式不与其他系统对齐 | 带 NullNode/WRITE_BIGDECIMAL_AS_PLAIN 等需要显式配置 |
// ✅ Spring Boot 配置(ObjectMapper全局)
@Configuration
public class JacksonConfig {
@Bean
public Jackson2ObjectMapperBuilderCustomizer customizer() {
return builder -> builder
.simpleDateFormat("yyyy-MM-dd HH:mm:ss")
.serializationInclusion(JsonInclude.Include.NON_NULL)
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.featuresToEnable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
}
}
// ✅ 注解方式
@Data
public class UserVO {
@JsonProperty("user_name") // JSON字段重命名
private String username;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@JsonIgnore // 序列化时忽略
private String password;
@JsonView(Views.Detail.class) // 仅详情视图返回
private String email;
}
// ✅ TypeReference 反序列化
List<User> users = objectMapper.readValue(json,
new TypeReference<List<User>>(){});
// ✅ Null值处理规则
objectMapper.configOverride(String.class)
.setInclude(JsonInclude.Value.construct(
JsonInclude.Include.NON_NULL, // null string → null
JsonInclude.Include.NON_NULL
));
本技能不收集、存储或传输任何用户数据。
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
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 包名。/