• 096实战 在windows下新建maven项目


    1.拷贝settings到.m2文件下

      

    2.修改文件

      

    3.新建Project项目

      

    4.转换为maven项目

      config下转换

    5.拷贝pom文件

      1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      2   <modelVersion>4.0.0</modelVersion>
      3   <groupId>com.ibeifeng</groupId>
      4   <artifactId>transformer</artifactId>
      5   <version>0.0.1</version>
      6 
      7   <properties>
      8     <hadoop.version>2.5.0-cdh5.3.6</hadoop.version>
      9     <hbase.version>0.98.6-cdh5.3.6</hbase.version>
     10     <hive.version>0.13.1-cdh5.3.6</hive.version>
     11     <mysql.version>5.1.18</mysql.version>
     12     <gson.version>2.6.2</gson.version>
     13     <uasparser.version>0.6.1</uasparser.version>
     14   </properties>
     15 
     16   <repositories>
     17     <!-- 指定该项目可以从哪些地方下载依赖包 --> 
     18     <repository>
     19       <id>aliyun</id>
     20       <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
     21     </repository>
     22     <repository>
     23       <id>cloudera</id>
     24       <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
     25     </repository>
     26     <repository>
     27       <id>jboss</id>
     28       <url>http://repository.jboss.org/nexus/content/groups/public</url>
     29     </repository>
     30   </repositories>
     31 
     32   <dependencies>
     33     <dependency>
     34       <groupId>org.apache.hadoop</groupId>
     35       <artifactId>hadoop-client</artifactId>
     36       <version>${hadoop.version}</version>
     37     </dependency>
     38 
     39     <dependency>
     40       <groupId>org.apache.hbase</groupId>
     41       <artifactId>hbase-client</artifactId>
     42       <version>${hbase.version}</version>
     43     </dependency>
     44 
     45     <dependency>
     46       <groupId>org.apache.hbase</groupId>
     47       <artifactId>hbase-server</artifactId>
     48       <version>${hbase.version}</version>
     49     </dependency>
     50 
     51     <dependency>
     52       <groupId>org.apache.hive</groupId>
     53       <artifactId>hive-exec</artifactId>
     54       <version>${hive.version}</version>
     55     </dependency>
     56 
     57     <!-- mysql start -->
     58     <dependency>
     59       <groupId>mysql</groupId>
     60       <artifactId>mysql-connector-java</artifactId>
     61       <version>${mysql.version}</version>
     62     </dependency>
     63     <!-- mysql end -->
     64 
     65     <dependency>
     66       <groupId>cz.mallat.uasparser</groupId>
     67       <artifactId>uasparser</artifactId>
     68       <version>${uasparser.version}</version>
     69     </dependency>
     70 
     71     <dependency>
     72       <groupId>com.google.code.gson</groupId>
     73       <artifactId>gson</artifactId>
     74       <version>${gson.version}</version>
     75     </dependency>
     76   </dependencies>
     77 
     78   <profiles>
     79     <!-- 指定环境 -->
     80     <profile>
     81       <!-- 指定本地运行环境,windows环境 -->
     82       <id>local</id>
     83       <activation>
     84         <!-- 指定默认环境是local -->
     85         <activeByDefault>true</activeByDefault>
     86       </activation>
     87       <build>
     88         <plugins>
     89           <plugin>  
     90             <!-- 支持多个不同文件夹中的java代码进行编译 -->
     91             <groupId>org.codehaus.mojo</groupId>
     92             <artifactId>build-helper-maven-plugin</artifactId>
     93             <version>1.4</version>
     94             <executions>
     95               <execution>
     96                 <id>add-source</id>  
     97                 <phase>generate-sources</phase>  
     98                 <goals>  
     99                   <goal>add-source</goal>  
    100                 </goals>  
    101                 <configuration>  
    102                   <sources>  
    103                     <source>${basedir}/src/main/java</source>
    104                     <source>${basedir}/src/main/extr</source>
    105                   </sources>
    106                 </configuration>  
    107               </execution>  
    108             </executions>  
    109           </plugin>
    110         </plugins>
    111       </build>
    112     </profile>
    113 
    114     <profile>
    115       <!-- hadoop环境运行, linux环境 -->
    116       <id>dev</id>
    117       <build>
    118         <plugins>
    119           <plugin>  
    120             <groupId>org.codehaus.mojo</groupId>
    121             <artifactId>build-helper-maven-plugin</artifactId>
    122             <version>1.4</version>
    123             <executions>
    124               <execution>
    125                 <id>add-source</id>  
    126                 <phase>generate-sources</phase>  
    127                 <goals>  
    128                   <goal>add-source</goal>  
    129                 </goals>  
    130                 <configuration>  
    131                   <sources>  
    132                     <source>${basedir}/src/main/java</source>
    133                   </sources>
    134                 </configuration>  
    135               </execution>  
    136             </executions>  
    137           </plugin>
    138 
    139           <plugin>
    140             <!-- 该插件的作用是将jar文件打包到最终形成的项目jar文件中 -->
    141             <groupId>org.apache.maven.plugins</groupId>
    142             <artifactId>maven-shade-plugin</artifactId>
    143             <version>2.1</version>
    144             <executions>
    145               <execution>
    146                 <phase>package</phase>
    147                 <goals>
    148                   <goal>shade</goal>
    149                 </goals>
    150                 <configuration>
    151                   <artifactSet>
    152                     <includes>
    153                       <include>cz.mallat.uasparser:uasparser</include>
    154                       <include>net.sourceforge.jregex:jregex</include>
    155                       <include>mysql:mysql-connector-java</include>
    156                     </includes>
    157                   </artifactSet>
    158                 </configuration>
    159               </execution>
    160             </executions>
    161           </plugin>
    162         </plugins>
    163       </build>
    164     </profile>
    165   </profiles>
    166 
    167   <build>
    168     <testSourceDirectory>src/test/java</testSourceDirectory>
    169     <plugins>
    170       <plugin>
    171         <artifactId>maven-compiler-plugin</artifactId>
    172         <version>3.3</version>
    173         <configuration>
    174           <source>1.7</source>
    175           <target>1.7</target>
    176           <encoding>utf8</encoding> <!-- 默认是gbk -->
    177         </configuration>
    178       </plugin>
    179     </plugins>
    180   </build>
    181 </project>

      

    6.新建目录

      src/main/java

      src/main/resources

      src/test/java

    7.拷贝java下的所有程序到src/main/java

      

    8.拷贝resources配置到src/main/resources

      

    9.拷贝ip到主目录

      

    二:测试

    1.程序

      

     2.结果 

    {os=Windows, u_sd=6D4F89C0-E17B-45D0-BFE0-059644C1878D, b_iev=Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36, bf_sid=33cbf257-3b11-4abd-ac70-c5fc47afb797_11177014, os_v=Windows XP, c_time=1450569596991, b_rst=1440*900, l=zh-CN, s_time=1450569601351, ver=1, u_ud=4B16B8BB-D6AA-4118-87F8-C58680D22657, city=宝山区, country=中国, ip=114.92.217.149, u_nu=1, browser=Chrome, province=上海市, pl=website, browser_v=45.0.2454.101, en=e_l, sdk=js}

  • 相关阅读:
    四元数
    Advanced Packaging Tool
    离散
    Functional programming
    异步传输同步传输
    没有动态库链接:可执行的文件大小一个就有几百兆 DynamicLink Libraries
    Levenshtein distance
    arguments
    prototype linkage can reduce object initialization time and memory consumption
    similar_text
  • 原文地址:https://www.cnblogs.com/juncaoit/p/6212981.html
Copyright © 2020-2023  润新知