标签:cas XML 串处理 group excel span news 依赖 into
整理一些小工具 の 依赖方便用的时候好找一些
jackson:主要用于json 处理:Java对象与Json 互相转换
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.10.3</version> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.10.3</version> </dependency>
简单例子
data = mapper.readValue(jsonData, 希望转的类型比如 User.class); // jsonData 为json字符串String类型就行, javaType java对象
转换成List <Map
ObjectMapper mapper = new ObjectMapper(); CollectionType listType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, HashMap.class); data = mapper.readValue(jsonData, listType);
common-lang3 :工具包
<dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency>
比如有:字符串处理 StringUtils.xxx() 数组处理ArrayUtils.xxx() 等等等等
比如可以判断两个数组相同 用这个就方便了不少、还有int数组变字符串数组等等 这里就不多写了
Objects.deepEquals(new int[] {1,2,3},new int[] {1,2,4});
poi 就不多说了
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.15</version> </dependency> <!-- poi office 2007需要的jar包 --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.15</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>3.15</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>ooxml-schemas</artifactId> <version>1.3</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-scratchpad</artifactId> <version>3.15</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-excelant</artifactId> <version>3.15</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-examples</artifactId> <version>3.15</version> </dependency>
EasyPoi
<!--excel导入导出--> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-web</artifactId> <version>4.0.0</version> </dependency>
教程:http://easypoi.mydoc.io/#text_202982
fastjson :json对象与JavaBean对象的转换
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.47</version> </dependency>
举个例子:
JSONObject json=JSONObject.parseObject(jsonStr); //jsonStr 为字符串 转换为json 对象 ;然后就可以从对象里取东西啦 json.get("xxx") 这个可以跟jackson 做个比较~!
String jsonString = json.toJSONString(对象); //反过来
pinyin4j :中文字符与拼音之间的转换
<dependency> <groupId>com.belerweb</groupId> <artifactId>pinyin4j</artifactId> <version>2.5.0</version> </dependency>
比如
public static String getPinyin(String str) { char[] charArr = str.toCharArray(); String[] newStr = new String[charArr.length]; String re = ""; HanyuPinyinOutputFormat fmt = new HanyuPinyinOutputFormat(); fmt.setCaseType(HanyuPinyinCaseType.LOWERCASE); fmt.setToneType(HanyuPinyinToneType.WITHOUT_TONE); fmt.setVCharType(HanyuPinyinVCharType.WITH_V); for (int i = 0; i < charArr.length; i++) { // 判断是否为汉字字符 if (java.lang.Character.toString(charArr[i]).matches("[\\u4E00-\\u9FA5]+")) { try { newStr = PinyinHelper.toHanyuPinyinStringArray(charArr[i], fmt); } catch (BadHanyuPinyinOutputFormatCombination e) { e.printStackTrace(); } re += newStr[0]; } else { re += java.lang.Character.toString(charArr[i]); } } return re; }
barcode4j 生成条形码
<dependency> <groupId>net.sf.barcode4j</groupId> <artifactId>barcode4j</artifactId> <version>2.1</version> </dependency>
jstl :
<dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency>
commons-codec:BASE64处理
<!-- BASE64处理 --> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.11</version> </dependency>
commons-fileupload: 上传文件
<!-- 上传文件依赖 --> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.3</version> </dependency>
swagger
<!--swagger--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency>
oshi-core: 获取硬件系统信息 比如cpu 操作系统什么的。
<dependency> <groupId>com.github.oshi</groupId> <artifactId>oshi-core</artifactId> <version>3.9.1</version> </dependency>
== 还没写完 ==
@
标签:cas XML 串处理 group excel span news 依赖 into
原文地址:https://www.cnblogs.com/DarGi2019/p/12625889.html