Maven 常用工具类整理

 

目录

  一、Apache Commons

    1.1、字符串处理

    1.2、集合操作

    1.3、IO操作

    1.4、编解码操作

  二、Google Guava

    2.1、多场景使用

    2.2、guava-retrying

  三、日志相关

    3.1、log4j

    3.2、slf4j

  四、其他工具

    4.1、lombok

  五、框架相关

    5.1、Mybatis

    

 

 

 

 

 

 

 

    

一、Apache Commons

1.1、字符串处理

  常用的比如StringUtils... 

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.8.1</version>
</dependency>

  

1.2、集合操作

  常用的比如CollectionUtils、MapUtils...

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-collections4</artifactId>
    <version>4.3</version>
</dependency>

  

1.3、IO操作

  比如FileUtils、IOUtils...

<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.6</version>
</dependency>

  

1.4、编解码操作

  各种加密、编码、解码的各种工具类

<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
<dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    <version>1.13</version>
</dependency>

  

二、Google Guava

2.1、多场景使用

  覆盖字符串处理、集合操作、并发、缓存.....参考:学习使用Guava(基本工具)

<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>28.0-jre</version>
</dependency>

  

2.2、guava-retrying

  guava-retrying是基于guava的一个库,参考:学习使用Guava Retryer

<!-- https://mvnrepository.com/artifact/com.github.rholder/guava-retrying -->
<dependency>
    <groupId>com.github.rholder</groupId>
    <artifactId>guava-retrying</artifactId>
    <version>2.0.0</version>
</dependency>

  

三、日志相关

  3.1、log4j

  v1的用法可以参考:log4j v1版本的配置和使用

<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>

  

  v2的用法可以参考:https://www.cnblogs.com/-beyond/p/10102035.html

<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.13.0</version>
</dependency>

  

  3.2、slf4j

  slf4j依赖log4j,下面是依赖log4j v2的pom,需要先创建log4j2.xml配置文件,参考上面log4j2的配置

<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl -->
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-slf4j-impl</artifactId>
    <version>2.12.1</version>
    <scope>test</scope>
</dependency>

  

 

 

四、其他工具

4.1、lombok

  lombok的用法参考:https://www.cnblogs.com/-beyond/p/11206793.html

<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.8</version>
    <scope>provided</scope>
</dependency>

  

五、框架相关

5.1、Mybatis

  除了mybatis本身的jar包外,还需要mysql-jdbc驱动:

<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>3.5.4</version>
</dependency>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.19</version>
</dependency>

  

 

 

posted @ 2019-11-15 20:08  寻觅beyond  阅读(2747)  评论(0编辑  收藏  举报
返回顶部