# jackson-dict-plus-spring-boot-starter **Repository Path**: Axiu_J/jackson-dict-plus-spring-boot-starter ## Basic Information - **Project Name**: jackson-dict-plus-spring-boot-starter - **Description**: 为jackson开发的插件,方便向对象中追加字典翻译字段。 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2022-10-10 - **Last Updated**: 2024-06-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # jackjson-dict-plus-boot-start jackson-dict-plus-boot-start 是一个jackson插件,提供无感的字典翻译工作。 ##使用 1. 引入依赖 ~~~xml top.axiuj jackson-dict-plus-spring-boot-starter ${jackson.dict.plus.version} ~~~ 2. 实现DictFieldService方法。 ~~~java @Service public class DictConfig implements DictFieldService { @Override public HashMap> getDictTable() { HashMap> map = new HashMap<>(); HashMap map1 = new HashMap<>(); map1.put("0", "0对应的值"); map1.put("1", "1对应的值"); map1.put("2", "2对应的值"); map1.put("3", "3对应的值"); map.put("type", map1); map1 = new HashMap<>(); map1.put("0", "0对"); map1.put("1", "1对"); map1.put("2", "2对"); map1.put("3", "3对"); map.put("gt", map1); return map; } @Override public String getV(String type, String key) { HashMap> map = new HashMap<>(); HashMap map1 = new HashMap<>(); map1.put("0", "0对应的值"); map1.put("1", "1对应的值"); map1.put("2", "2对应的值"); map1.put("3", "3对应的值"); map.put("type", map1); map1 = new HashMap<>(); map1.put("0", "0对"); map1.put("1", "1对"); map1.put("2", "2对"); map1.put("3", "3对"); map.put("gt", map1); return map.get(type).get(key); } } ~~~ 3. 属性上加上注解@IDict ~~~java public class gis { @IDict("type") private String type; public String getType() { return type; } public void setType(String type) { this.type = type; } } ~~~ 5. 测试结果 {"type":"2","type_Dict":"2对应的值"} ## 说明 找到对应value后,会在对象中添加上一个_Dict结尾字段。