构建dubbo分布式平台-maven构建ant-utils工具项目

Posted 咨同科技

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了构建dubbo分布式平台-maven构建ant-utils工具项目相关的知识,希望对你有一定的参考价值。



上一篇我们介绍《构建dubbo分布式平台-maven构建ant-framework核心代码Base封装》,今天重点讲解的是ant-utils工具包的构建过程。

 

导语:ant-utils是核心工具包,提供整个架构通用工具类库

 

1. 创建ant-utils工具包子项目,继承ant-parent根项目,其中pom.xml配置如下:

 

Xml代码  

  1. <span style="font-size: 14px;"><?xml version="1.0"?>  

  2. <project  

  3.     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"  

  4.     xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  

  5.     <modelVersion>4.0.0</modelVersion>  

  6.     <parent>  

  7.         <groupId>com.sml.sz</groupId>  

  8.         <artifactId>ant-project</artifactId>  

  9.         <version>1.0.0</version>  

  10.     </parent>  

  11.     <artifactId>ant-utils</artifactId>  

  12.     <name>ant-utils</name>  

  13.     <url>http://maven.apache.org</url>  

  14.     <description>ant核心工具包,提供整个架构通用工具类库</description>  

  15.   

  16.     <dependencies>  

  17.         <!-- 通用工具包 -->  

  18.         <dependency>  

  19.             <groupId>org.apache.commons</groupId>  

  20.             <artifactId>commons-lang3</artifactId>  

  21.             <version>${commons-lang3.version}</version>  

  22.         </dependency>  

  23.         <dependency>  

  24.             <groupId>commons-io</groupId>  

  25.             <artifactId>commons-io</artifactId>  

  26.             <version>${commons-io.version}</version>  

  27.         </dependency>  

  28.         <dependency>  

  29.             <groupId>commons-codec</groupId>  

  30.             <artifactId>commons-codec</artifactId>  

  31.             <version>${commons-codec.version}</version>  

  32.         </dependency>  

  33.         <dependency>  

  34.             <groupId>commons-fileupload</groupId>  

  35.             <artifactId>commons-fileupload</artifactId>  

  36.             <version>${commons-fileupload.version}</version>  

  37.         </dependency>  

  38.         <dependency>  

  39.             <groupId>commons-beanutils</groupId>  

  40.             <artifactId>commons-beanutils</artifactId>  

  41.             <version>${commons-beanutils.version}</version>  

  42.             <exclusions>  

  43.                 <exclusion>  

  44.                     <groupId>commons-logging</groupId>  

  45.                     <artifactId>commons-logging</artifactId>  

  46.                 </exclusion>  

  47.             </exclusions>  

  48.         </dependency>  

  49.   

  50.         <!-- jackson json 包-->  

  51.         <dependency>  

  52.             <groupId>com.fasterxml.jackson.core</groupId>  

  53.             <artifactId>jackson-core</artifactId>  

  54.             <version>${jackson.version}</version>  

  55.         </dependency>  

  56.         <dependency>  

  57.             <groupId>com.fasterxml.jackson.core</groupId>  

  58.             <artifactId>jackson-databind</artifactId>  

  59.             <version>${jackson.version}</version>  

  60.         </dependency>  

  61.         <dependency>  

  62.             <groupId>com.fasterxml.jackson.core</groupId>  

  63.             <artifactId>jackson-annotations</artifactId>  

  64.             <version>${jackson.version}</version>  

  65.         </dependency>  

  66.         <dependency>  

  67.             <groupId>com.fasterxml.jackson.module</groupId>  

  68.             <artifactId>jackson-module-jaxb-annotations</artifactId>  

  69.             <version>${jackson.version}</version>  

  70.         </dependency>  

  71.   

  72.         <!-- xstream包,将Java对象和xml文档相互转换-->  

  73.         <dependency>  

  74.             <groupId>com.thoughtworks.xstream</groupId>  

  75.             <artifactId>xstream</artifactId>  

  76.             <version>${xstream.version}</version>  

  77.         </dependency>  

  78.   

  79.         <!-- pojo copy javaBean的映射工具包,可以进行简单的属性映射、复杂的类型映射、双向映射、递归映射-->  

  80.         <dependency>  

  81.             <groupId>net.sf.dozer</groupId>  

  82.             <artifactId>dozer</artifactId>  

  83.             <version>${dozer.version}</version>  

  84.         </dependency>  

  85.   

  86.         <!-- freemarker 模板引擎包 -->  

  87.         <dependency>  

  88.             <groupId>org.freemarker</groupId>  

  89.             <artifactId>freemarker</artifactId>  

  90.             <version>${freemarker.version}</version>  

  91.         </dependency>  

  92.   

  93.         <!-- java邮件发送 -->  

  94.         <dependency>  

  95.             <groupId>javax.mail</groupId>  

  96.             <artifactId>mail</artifactId>  

  97.             <version>${email.version}</version>  

  98.         </dependency>  

  99.         <dependency>  

  100.             <groupId>javax.activation</groupId>  

  101.             <artifactId>activation</artifactId>  

  102.             <version>1.1.1</version>  

  103.         </dependency>  

  104.   

  105.         <!-- POI相关的包 -->  

  106.         <dependency>  

  107.             <groupId>org.apache.poi</groupId>  

  108.             <artifactId>poi</artifactId>  

  109.             <version>${poi.version}</version>  

  110.         </dependency>  

  111.         <dependency>  

  112.             <groupId>org.apache.poi</groupId>  

  113.             <artifactId>poi-ooxml</artifactId>  

  114.             <version>${poi.version}</version>  

  115.         </dependency>  

  116.         <dependency>  

  117.             <groupId>org.apache.poi</groupId>  

  118.             <artifactId>poi-ooxml-schemas</artifactId>  

  119.             <version>${poi.version}</version>  

  120.         </dependency>  

  121.   

  122.         <!-- 图片数据元提取  -->  

  123.         <dependency>  

  124.             <groupId>com.drewnoakes</groupId>  

  125.             <artifactId>metadata-extractor</artifactId>  

  126.             <version>2.6.2</version>  

  127.         </dependency>  

  128.   

  129.         <!-- 条形码、二维码生成 -->  

  130.         <dependency>  

  131.             <groupId>com.google.zxing</groupId>  

  132.             <artifactId>core</artifactId>  

  133.             <version>2.2</version>  

  134.         </dependency>  

  135.         <dependency>  

  136.             <groupId>com.google.zxing</groupId>  

  137.             <artifactId>javase</artifactId>  

  138.             <version>2.2</version>  

  139.         </dependency>  

  140.   

  141.         <!-- 缓存相关包 -->  

  142.         <dependency>  

  143.             <groupId>net.sf.ehcache</groupId>  

  144.             <artifactId>ehcache-core</artifactId>  

  145.             <version>${ehcache.version}</version>  

  146.         </dependency>  

  147.         <dependency>  

  148.             <groupId>net.sf.ehcache</groupId>  

  149.             <artifactId>ehcache-web</artifactId>  

  150.             <version>${ehcache-web.version}</version>  

  151.         </dependency>  

  152.         <dependency>  

  153.             <groupId>redis.clients</groupId>  

  154.             <artifactId>jedis</artifactId>  

  155.             <version>2.5.1</version>  

  156.         </dependency>  

  157.   

  158.         <!-- spring相关包 -->  

  159.         <dependency>  

  160.             <groupId>org.springframework</groupId>  

  161.             <artifactId>spring-context-support</artifactId>  

  162.             <version>${spring.version}</version>  

  163.         </dependency>  

  164.           

  165.         <!-- httpclient 依赖包,使用的时候才依赖 -->  

  166.         <dependency>  

  167.             <groupId>org.apache.httpcomponents</groupId>  

  168.             <artifactId>httpclient</artifactId>  

  169.             <version>4.5.2</version>  

  170.         </dependency>  

  171.     </dependencies>  

  172.     <profiles>  

  173.         <profile>  

  174.             <id>sit</id>  

  175.             <activation>  

  176.                 <property>  

  177.                     <name>environment.type</name>  

  178.                     <value>sit</value>  

  179.                 </property>  

  180.             </activation>  

  181.             <build>  

  182.                 <plugins>  

  183.                     <plugin>  

  184.                         <groupId>com.google.code.maven-replacer-plugin</groupId>  

  185.                         <artifactId>replacer</artifactId>  

  186.                         <configuration>  

  187.                             <includes>  

  188.                                 <include>target/classes/logback.properties</include>  

  189.                             </includes>  

  190.                             <replacements>  

  191.                                 <replacement>  

  192.                                     <token>=dev</token>  

  193.                                     <value>=sit</value>  

  194.                                 </replacement>  

  195.                             </replacements>  

  196.                         </configuration>  

  197.                     </plugin>  

  198.                 </plugins>  

  199.             </build>  

  200.         </profile>  

  201.         <profile>  

  202.             <id>uat</id>  

  203.             <activation>  

  204.                 <property>  

  205.                     <name>environment.type</name>  

  206.                     <value>uat</value>  

  207.                 </property>  

  208.             </activation>  

  209.             <build>  

  210.                 <plugins>  

  211.                     <plugin>  

  212.                         <groupId>com.google.code.maven-replacer-plugin</groupId>  

  213.                         <artifactId>replacer</artifactId>  

  214.                         <configuration>  

  215.                             <includes>  

  216.                                 <include>target/classes/logback.properties</include>  

  217.                             </includes>  

  218.                             <replacements>  

  219.                                 <replacement>  

  220.                                     <token>=dev</token>  

  221.                                     <value>=uat</value>  

  222.                                 </replacement>  

  223.                             </replacements>  

  224.                         </configuration>  

  225.                     </plugin>  

  226.                 </plugins>  

  227.             </build>  

  228.         </profile>  

  229.         <profile>  

  230.             <id>performance</id>  

  231.             <activation>  

  232.                 <property>  

  233.                     <name>environment.type</name>  

  234.                     <value>performance</value>  

  235.                 </property>  

  236.             </activation>  

  237.             <build>  

  238.                 <plugins>  

  239.                     <plugin>  

  240.                         <groupId>com.google.code.maven-replacer-plugin</groupId>  

  241.                         <artifactId>replacer</artifactId>  

  242.                         <configuration>  

  243.                             <includes>  

  244.                                 <include>target/classes/logback.properties</include>  

  245.                             </includes>  

  246.                             <replacements>  

  247.                                 <replacement>  

  248.                                     <token>=dev</token>  

  249.                                     <value>=perf</value>  

  250.                                 </replacement>  

  251.                             </replacements>  

  252.                         </configuration>  

  253.                     </plugin>  

  254.                 </plugins>  

  255.             </build>  

  256.         </profile>  

  257.         <profile>  

  258.             <id>production</id>  

  259.             <activation>  

  260.                 <property>  

  261.                     <name>environment.type</name>  

  262.                     <value>production</value>  

  263.                 </property>  

  264.             </activation>  

  265.             <build>  

  266.                 <plugins>  

  267.                     <plugin>  

  268.                         <groupId>com.google.code.maven-replacer-plugin</groupId>  

  269.                         <artifactId>replacer</artifactId>  

  270.                         <configuration>  

  271.                             <includes>  

  272.                                 <include>target/classes/logback.properties</include>  

  273.                             </includes>  

  274.                             <replacements>  

  275.                                 <replacement>  

  276.                                     <token>=dev</token>  

  277.                                     <value>=prd</value>  

  278.                                 </replacement>  

  279.                             </replacements>  

  280.                         </configuration>  

  281.                     </plugin>  

  282.                 </plugins>  

  283.             </build>  

  284.         </profile>  

  285.     </profiles>  

  286. </project></span>  

 

 

2. 此项目中只包含了通用的工具类库,包括:配置文件、文件处理、手机短信、email邮箱处理、

redis缓存处理、collection集合处理、cookie处理、时间工具、freemarker模板工具、httpclient工具、

多线程等。

 

欢迎大家跟我一起学习《构建dubbo分布式平台》,希望大家持续关注后面的文章!


以上是关于构建dubbo分布式平台-maven构建ant-utils工具项目的主要内容,如果未能解决你的问题,请参考以下文章

构建dubbo分布式平台-maven代码结构

构建dubbo分布式平台-maven模块规划和平台功能导图

构建dubbo分布式平台-maven构建config配置项目

构建dubbo分布式平台-maven构建ant-utils工具项目

构建dubbo分布式平台-maven构建ant-utils工具项目

构建dubbo分布式平台-maven构建config配置项目