码迷,mamicode.com
首页 > 编程语言 > 详细

jar包依赖整理(一)

时间:2020-04-03 16:36:34      阅读:62      评论:0      收藏:0      [点我收藏+]

标签: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>
View Code

教程: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>
View Code


commons-codec:BASE64处理
技术图片
<!-- BASE64处理 -->
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>1.11</version>
            </dependency>
View Code

 

commons-fileupload: 上传文件

技术图片
<!-- 上传文件依赖 -->
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>1.3.3</version>
            </dependency>
View Code

 

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>    
View Code

 

oshi-core: 获取硬件系统信息 比如cpu 操作系统什么的。

技术图片
<dependency>
                <groupId>com.github.oshi</groupId>
                <artifactId>oshi-core</artifactId>
                <version>3.9.1</version>
            </dependency>
View Code

 

 

 

== 还没写完 ==

 

 

 

 

 

@

jar包依赖整理(一)

标签:cas   XML   串处理   group   excel   span   news   依赖   into   

原文地址:https://www.cnblogs.com/DarGi2019/p/12625889.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!