CDH版本java开发环境搭建

1. maven设置

 除了阿里云库,还需要引入 cdh, spring库。需要修改maven下面的配置文件setting.xml, 参考下面设置。

    <mirror>
      
      <id>nexus-aliyunid>
      <mirrorOf>*,!cloudera,!spring-releasesmirrorOf>
      <name>Nexus aliyunname>
      <url>http://maven.aliyun.com/nexus/content/groups/publicurl>
    mirror>

2. 在项目文件pom.xml中引入的是cdh对应版本的包

设置cdh库,spring库。

    <repositories>
        <repository>
            <id>clouderaid>
            <url>https://repository.cloudera.com/artifactory/cloudera-repos/url>
            <releases>
                <enabled>trueenabled>
            releases>
            <snapshots>
                <enabled>falseenabled>
            snapshots>
        repository>
        <repository>
            <id>spring-releasesid>
            <url>https://repo.spring.io/libs-releaseurl>
        repository>
    repositories>

依赖包需要加入cdh版本的

        <dependency>
            <groupId>eigenbasegroupId>
            <artifactId>eigenbase-propertiesartifactId>
            <version>1.1.4version>
        dependency>
        <dependency>
            <groupId>org.apache.hadoopgroupId>
            <artifactId>hadoop-commonartifactId>
            <version>2.6.0-cdh5.15.1version>
        dependency>
        <dependency>
            <groupId>org.apache.hivegroupId>
            <artifactId>hive-jdbcartifactId>
            <version>1.1.0-cdh5.15.1version>
        dependency>
        <dependency>
            <groupId>org.apache.hivegroupId>
            <artifactId>hive-execartifactId>
            <version>1.1.0-cdh5.15.1version>
        dependency>
        <dependency>
            <groupId>org.apache.hivegroupId>
            <artifactId>hive-metastoreartifactId>
            <version>1.1.0-cdh5.15.1version>
        dependency>
        <dependency>
            <groupId>org.apache.hadoopgroupId>
            <artifactId>hadoop-mapreduce-client-coreartifactId>
            <version>2.6.0-cdh5.15.1version>
        dependency>

其他的依赖包正常添加即可。

附上1个完成的pom文件。

<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">
    <modelVersion>4.0.0modelVersion>
    <groupId>com.etlgroupId>
    <artifactId>suyandvartifactId>
    <version>1.0.0version>
    <packaging>jarpackaging>
    <properties>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    properties>

    <repositories>
        <repository>
            <id>clouderaid>
            <url>https://repository.cloudera.com/artifactory/cloudera-repos/url>
            <releases>
                <enabled>trueenabled>
            releases>
            <snapshots>
                <enabled>falseenabled>
            snapshots>
        repository>
        <repository>
            <id>spring-releasesid>
            <url>https://repo.spring.io/libs-releaseurl>
        repository>
    repositories>

    <dependencies>
        <dependency>
            <groupId>eigenbasegroupId>
            <artifactId>eigenbase-propertiesartifactId>
            <version>1.1.4version>
        dependency>

        <dependency>
            <groupId>org.apache.hadoopgroupId>
            <artifactId>hadoop-commonartifactId>
            <version>2.6.0-cdh5.15.1version>
        dependency>
        <dependency>
            <groupId>org.apache.hivegroupId>
            <artifactId>hive-jdbcartifactId>
            <version>1.1.0-cdh5.15.1version>
        dependency>
        <dependency>
            <groupId>org.apache.hivegroupId>
            <artifactId>hive-execartifactId>
            <version>1.1.0-cdh5.15.1version>
        dependency>
        <dependency>
            <groupId>org.apache.hivegroupId>
            <artifactId>hive-metastoreartifactId>
            <version>1.1.0-cdh5.15.1version>
        dependency>
        <dependency>
            <groupId>org.apache.hadoopgroupId>
            <artifactId>hadoop-mapreduce-client-coreartifactId>
            <version>2.6.0-cdh5.15.1version>
        dependency>


        <dependency>
            <groupId>org.apache.commonsgroupId>
            <artifactId>commons-lang3artifactId>
            <version>3.3.2version>
        dependency>
        <dependency>
            <groupId>com.squareup.okhttp3groupId>
            <artifactId>okhttpartifactId>
            <version>3.11.0version>
        dependency>
        <dependency>
            <groupId>redis.clientsgroupId>
            <artifactId>jedisartifactId>
            <version>2.9.0version>
        dependency>
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
            <version>5.1.46version>
        dependency>
        <dependency>
            <groupId>log4jgroupId>
            <artifactId>log4jartifactId>
            <version>1.2.17version>
        dependency>
        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>fastjsonartifactId>
            <version>1.2.51version>
        dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.coregroupId>
            <artifactId>jackson-coreartifactId>
            <version>2.6.7version>
        dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.coregroupId>
            <artifactId>jackson-databindartifactId>
            <version>2.6.7version>
        dependency>


    dependencies>
    <build>
        <finalName>suyandvfinalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-pluginartifactId>
                
                <configuration>
                    <source>1.8source>
                    <target>1.8target>
                    <encoding>UTF-8encoding>
                configuration>
            plugin>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-dependency-pluginartifactId>
                <executions>
                    <execution>
                        <id>copy-dependenciesid>
                        <phase>prepare-packagephase>
                        <goals>
                            <goal>copy-dependenciesgoal>
                        goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/liboutputDirectory>
                            <overWriteReleases>falseoverWriteReleases>
                            <overWriteSnapshots>falseoverWriteSnapshots>
                            <overWriteIfNewer>trueoverWriteIfNewer>
                        configuration>
                    execution>
                executions>
            plugin>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-jar-pluginartifactId>
                <version>2.4version>
                <configuration>
                    <archive>
                        
                        <manifest>
                            <addClasspath>trueaddClasspath>
                            <classpathPrefix>lib/classpathPrefix>
                            <mainClass>mainClass>
                        manifest>
                    archive>
                configuration>
            plugin>
        plugins>
    build>


project>
View Code

 

转载于:https://www.cnblogs.com/30go/p/9892087.html

你可能感兴趣的:(CDH版本java开发环境搭建)