Updated on 2026-06-29 GMT+08:00

Commissioning the Hive Spring Boot Sample Program

This section applies to MRS 3.3.0 or later.

Running the Spring Boot Sample Project in CLI

  1. Click Terminal in the lower left corner of the IDEA page to access the terminal. Run the mvn clean package command to perform compilation.

    If "BUILD SUCCESS" is displayed, the compilation is successful. A JAR file containing the -with-dependencies field is generated in the target directory of the sample project.

  2. Create a directory on Windows or Linux as the running directory, for example, D:\hive-rest-client-example (Windows) or /opt/hive-rest-client-example (Linux). Place the JAR file in 1 to this directory, and create the src/main/resources subdirectory in the directory. Copy all files in the resources directory of the hive-rest-client-example project to resources.
  3. Run the following commands to start the Spring Boot service:

    • Commands for Windows:

      cd /d d:\hive-rest-client-example

      java -jar hive-rest-client-example-8.1.0.1-3.7.0-SNAPSHOT-jar-with-dependencies.jar

    • Commands for Linux:

      chmod +x /opt/hive-rest-client-example -R

      cd /opt/hive-rest-client-example

      java -jar hive-rest-client-example-8.1.0.1-3.7.0-SNAPSHOT-jar-with-dependencies.jar

    The preceding JAR file name is for reference only. Replace it with the actual one.

  4. Call the Spring Boot sample API of Hive to trigger running the sample code.

    • Running method in Windows:

      Open the browser and enter http://localhost:8080/hive/example/executesql in the address box.

    • Running method in Linux:

      Run the curl http://localhost:8080/hive/example/executesql command on the node where the JAR file is stored in 2.

    The following information may be printed in the log when the sample code is executed. Although the log level is ERROR, the execution result is not affected.

    ERROR 51320 --- [c-8-EventThread] o.a.c.framework.imps.EnsembleTracker     : Invalid config event received: {version=100000000, server.48=IP address of the ZooKeeper node:ZooKeeper port number:ZooKeeper port number:participant...}

  5. View the HQL query results in the sample code.

    • The following information is displayed if the sample project is successful in Windows:
      =========================== Hive Example Start ===========================
      Start create table.
      Table created successfully.
      Start to insert data into the table.
      Inserting data to the table succeeded.
      Start to query table data.
      Query result :
      employees_infoa.id    employees_infoa.age    employees_infoa.name
      1    31    SJK
      2    25    HS
      3    28    HT
      
      Querying table data succeeded.
      Start to delete the table.
      Table deleted successfully.
      =========================== Hive Example End ===========================
    • The following information is displayed if the sample project is successful in Linux:
      =========================== Hive Example Start ===========================
      Start create table.
      Table created successfully.
      Start to insert data into the table.
      Inserting data to the table succeeded.
      Start to query table data.
      Query result :
      employees_infoa.id    employees_infoa.age    employees_infoa.name
      1    31    SJK
      2    25    HS
      3    28    HT
      
      Querying table data succeeded.
      Start to delete the table.
      Table deleted successfully.
      =========================== Hive Example End ===========================