Updated on 2022-09-14 GMT+08:00

Configuring and Importing Sample Projects

Scenario

MapReduce provides sample projects for multiple scenarios to help you quickly learn MapReduce projects.

The procedure of importing MapReduce example codes is described as follows: Figure 1 shows the procedure.

Figure 1 Procedure of importing sample projects

Procedure

  1. Obtain the sample project mapreduce-example-normal in the src directory where the sample code is decompressed. For details, see Obtaining Sample Projects from Huawei Mirrors.
  2. Import the example project to the IntelliJ IDEA development environment.

    1. Open IntelliJ IDEA and choose File > Open.
    2. Choose the directory of the example project mapreduce-example-normal. Click OK.

  3. Set the IntelliJ IDEA text file coding format to prevent garbled characters.

    1. On the IntelliJ IDEA menu bar, choose File > Settings.

      The Settings window is displayed.

    2. Choose Editor > File Encodings from the navigation tree. In the "Global Encoding" and "Project Encodings" area, set the value to UTF-8, click Apply, and click OK, as shown in Figure 2
      Figure 2 Setting the IntelliJ IDEA coding format

  4. Add the configuration information such as the address of the open-source image repository to the setting.xml configuration file of the local Maven by referring to Configuring Huawei Open-Source Mirrors.

    On the IntelliJ IDEA page, select File > Settings > Build, Execution, Deployment > Build Tools > Maven, select Override next to User settings file, and change the value of User settings file to the directory where the settings.xml file is stored. Ensure that the directory is <Local Maven installation directory>\conf\settings.xml.
    Figure 3 Directory for storing the settings.xml file

Reference

The dependency packages mapped to the sample projects of MapReduce are as follows:

  • MapReduce statistics sample project

    No additional jars.

  • MapReduce accessing multi-components sample project
    • If you want to use the multi-component accessing sample project after importing a sample project, ensure that the HBase service have been installed in the cluster.
    • If you do not use the multi-components accessing sample project, you can ignore errors about the multi-components accessing sample project as long as the compilation of the statistics sample project is not affected. Otherwise, delete the files about the multi-components accessing sample project after importing the sample projects.