Importing and Configuring a Spring Boot Sample Project
Scenario
Run the Spring Boot interface sample code of MRS Hive.
In the following example, an application is developed by compiling a Spring Boot project to connect to Hive in Windows.
This section applies to MRS 3.3.0 or later.
Procedure
- Obtain the sample project folder hive-rest-client-example in the src\springboot\hive-examples directory where the sample code is decompressed. For details, see Obtaining the MRS Application Development Sample Project.
- Go to the client decompression path FusionInsight_Cluster_1_Services_ClientConfig\Hive\config and copy the core-site.xml and hiveclient.properties files to the hive-rest-client-example\src\main\resources directory of the sample project.
In MRS 3.3.1 and later versions, Hive allows you to add extension identifiers to JDBC connection strings. These extension identifiers are printed in HiveServer audit logs to distinguish SQL sources. If you need to configure an identifier, add the following content to the hive-jdbc-example\src\main\resources\hiveclient.properties file:
auditAddition=xxx
xxx is the custom identifier. The identifier can contain a maximum of 256 bytes and only letters, digits, underscores (_), commas (,), and colons (:) are allowed.
After the SQL statement is executed, the configured extension identifier is printed in the HiveServer audit log /var/log/Bigdata/audit/hive/hiveserver/hive-audit.log. The following is an example.

- Import the sample project to the IntelliJ IDEA development environment.
- On the menu bar of IntelliJ IDEA, choose File > Open....
- In the Open File or Project dialog box that is displayed, select the hive-rest-client-example folder and click OK. In Windows, the folder path cannot contain any space.
- Set the IntelliJ IDEA text file coding format to prevent garbled characters.
- On the menu bar of IntelliJ IDEA, choose File > Settings. The Settings window is displayed.
- In the left navigation pane, choose Editor > File Encodings. In the Project Encoding and Global Encoding areas, set the parameter to UTF-8. Click Apply and OK. Figure 1 Setting the IntelliJ IDEA coding format
- Set the JDK of the project.
- On the menu bar of IntelliJ IDEA, choose File > Settings. The Settings window is displayed.
- Choose Build, Execution, Deployment > Compiler > Java Compiler and select 8 from the Project bytecode version drop-down list box. Change the value of Target bytecode version in hive-rest-client-example to 8. Figure 2 Configuring the Target bytecode version
- Click Apply then OK.
- On the menu bar of IntelliJ IDEA, choose File > Project Structure.... The Project Structure window is displayed.
- Choose SDKs, click the plus sign (+), and select JDK. Figure 3 Adding the JDK
- On the Select Home Directory for JDK page that is displayed, select the JDK directory and click OK.
- Click Apply.
- Select Project, select the JDK added in SDKs from the SDK drop-down list box, and select 8 - Lambdas, type annotations etc. from the Language level drop-down list box. Figure 4 Configuring the Project
- Click Apply.
- Choose Modules. On the Sources tab page, change the value of Language level to 8 - Lambdas, type annotations etc.. Figure 5 Configuring the Modules
On the Dependencies tab page, change the value of Module SDK to the JDK added in SDKs.
Figure 6 Modifying the Module SDK
- Click Apply then OK.
- Configure Maven.
- 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 Image Repository.
- On the IntelliJ IDEA page, choose 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 7 Directory for storing the settings.xml file
- Click the drop-down list next to Maven home directory and select the Maven installation directory.
- Click Apply then OK.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot