Help Center/ AI DataLake/ devg/ Spark UDF Development Guide/ Calling Remote UDFs in Spark SQL Jobs/ Creating a Maven Project and Configuring the Project Structure
Updated on 2026-11-06 GMT+08:00

Creating a Maven Project and Configuring the Project Structure

Creating a Maven Project and Configuring the Project Structure

The following uses IntelliJ IDEA 2024.3.2.2 as an example.

  1. Start IntelliJ IDEA and choose File > New > Project.
    Figure 1 Creating a project
  1. Choose Maven Archetype and configure the following parameters:
    • Name: Enter a project name. In this example, the project name is MyRemoteUDF.
    • Location: Select a path for storing the project. In this example, the project is saved in D:\UDFTest.
    • JDK: Select the JDK 1.8.
    • Archetype: Select org.apache.maven.archetypes:maven-archetype-quickstart.

    Click Create to create the project.

    Figure 2 Creating a Maven project
  2. Choose src > main and right-click the java folder. Choose New > Package to create a package.
    Figure 3 Creating a package
    Set the package name as you need. In this example, the package name is com.huawei.demo. Then, press Enter.
    Figure 4 Setting the package name
  3. Create a Java Class file in the package path. In this example, the Java Class file is UDFDemo.
    Figure 5 Creating a Java class file
  4. Add the path for storing the JAR package.

    Click File > New > Directory to create a folder for storing the JAR package.

    Figure 6 Adding the path for storing the JAR package

    In this example, the folder name is lib. Press Enter to confirm the name.

    Figure 7 Setting the folder name
  5. Import the JAR package.
    1. Download the JAR package

      from https://repo.huaweicloud.com/repository/maven/huaweicloudsdk/com/huawei/mrs.

    2. After the download is complete, right-click the JAR package and choose Copy from the shortcut menu.
  6. Locate the lib directory of the project, paste it to the created lib folder, and click OK in the dialog box that is displayed.
    Figure 8 Pasting the JAR package to the lib folder
  7. Configure Project Structure.
    1. Click File > Project Structure.
      Figure 9 Clicking Project Structure
    1. On the navigation pane, choose Libraries. Then click + and select Java.
      Figure 10 Clicking Java
    2. Select the JAR package added to the lib folder and click OK.
      Figure 11 Selecting the JAR package added to the lib folder
    3. On the displayed Choose Roots dialog box, select only the first folder and click OK.
      Figure 12 Choose Roots dialog box
    4. Click OK as prompted.
      Figure 13 Clicking OK
  8. Click Artifacts. On the displayed page, click + and then choose JAR > From modules with dependencies.
    Figure 14 Choosing From modules with dependencies
  9. In the JAR files from libraries area, enable the first option and click OK.
    Figure 15 Clicking OK
  10. Click Apply and then OK.
    Figure 16 Configuring Artifacts