Help Center> MapReduce Service> Developer Guide (Normal_3.x)> Obtaining Sample Projects from Huawei Mirrors
Updated on 2023-08-31 GMT+08:00

Obtaining Sample Projects from Huawei Mirrors

Procedure

Building a sample project includes the following operations:

  1. Download the Maven project source code and configuration files of the sample project. For details, see Obtaining Sample Projects.
  2. Configure the Maven mirror repository of the SDK in Huawei Mirrors. For details, see Configuring Huawei Open-Source Mirrors.
  3. Build a complete Maven project based on user requirements.

Obtaining Sample Projects

Figure 1 Downloading sample code

Download the package to the local host and decompress it to obtain the sample code of the components.

For details about how to obtain the sample project of MRS 3.1.2-LTS, see Obtaining Sample Projects from Huawei Mirrors.

Configuring Huawei Open-Source Mirrors

Huawei provides Huawei Mirrors for you to download all dependency JAR files of sample projects. However, you need to download the rest dependency open-source JAR files from the Maven central repository or other custom repository address.

Before using a development tool to download the dependency JAR files in the local environment, ensure that the following conditions are met:

  • The local network is normal.

    Uses a browser and visit Huawei Mirrors to check whether the website can be accessed. If the access is abnormal, connect the local network.

  • The proxy is disabled for the development tool.

    Take the IntelliJ IDEA development tool of version 2020.2 as an example. Choose File > Settings > Appearance & Behavior > System Settings > HTTP Proxy, select No proxy, and click OK to save the configuration.

Perform the following steps to configure the open-source mirror warehouse.

  1. Check that JDK 1.8 or later and Maven 3.0 or later have been installed.
  2. Configure the Maven configuration file.

    • To overwrite the Maven configuration file, choose Huawei SDK > HuaweiCloud SDK at Huawei Mirrors, download the settings.xml file, and overwrite the <Maven installation directory>/conf/settings.xml file with the downloaded file.
    • (Optional) If you do not want to overwrite the Maven configuration file, manually modify the settings.xml configuration file or the pom.xml file of the component sample project to configure the mirror repository address. The configuration methods are as follows:
      • Configuration method 1: Modify the settings.xml configuration file.

        Add the following open-source mirror repository address to mirrors in the settings.xml configuration file.

        <mirror>
            <id>repo2</id>
            <mirrorOf>central</mirrorOf>
            <url>https://repo1.maven.org/maven2/</url>
        </mirror>

        Add the following mirror repository address to profiles in the settings.xml configuration file.

        <profile>
            <id>huaweicloudsdk</id>
            <repositories>
                <repository>
                    <id>huaweicloudsdk</id>
                    <url>https://repo.huaweicloud.com/repository/maven/huaweicloudsdk/</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
            </repositories>
        </profile>

        Add the following mirror repository address to the activeProfiles node in the settings.xml file.

        <activeProfile>huaweicloudsdk</activeProfile>
        • Huawei Mirrors does not provide third-party open-source JAR files. After configuring Huawei open-source mirrors, you need to separately configure third-party Maven mirror repository address.
        • When using the IntelliJ IDEA development tool, you can choose File > Settings > Build, Execution, Deployment > Build Tools > Maven to view the directory where the settings.xml file is stored.

      • Configuration method 2: Modify the pom.xml configuration file.
        Add the following mirror repository address directly to the pom.xml file in the secondary development sample project.
            <repositories>
        
                <repository>
                    <id>huaweicloudsdk</id>
                    <url>https://mirrors.huaweicloud.com/repository/maven/huaweicloudsdk/</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
        
                <repository>
                    <id>central</id>
                    <name>Maven Central</name>
                    <url>https://repo1.maven.org/maven2/</url>
                </repository>
        
            </repositories>

  3. Configure the default Maven code and JDK. Add the following information to profiles in the settings.xml configuration file:

    <profile>
    <id>JDK1.8</id>
    <activation>
    <activeByDefault>true</activeByDefault>
    <jdk>1.8</jdk>
    </activation>
    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
    </properties>
    </profile>