Build the environment

更新时间:
复制 MD 格式

This topic describes the requirements for building the SOFABoot environment. It mainly involves the installation and configuration of JDK and Maven.

Install JDK

Version requirements

SOFABoot is developed based on the Spring Boot framework and requires JDK version ≥ 8.

Installation steps

  1. Go to the Oracle official website to download and install the Java SE installation package that matches your operating system. For more information, see Install the JDK or Installation Guide.

  2. Configure system environment variables. For more information, see Introduction and Configuration of PATH and CLASSPATH Variables.

    • Windows systems:

      • JAVA_HOME: Enter the installation path of the JDK, as C:/Program Files/Java/jdk1.8.0_181.

      • PATH: Add the %JAVA_HOME%/bin folder path. Separate multiple paths with semicolons (;).

    • macOS and Linux: Example:

      export JAVA_HOME=/${path_to_jdk_dir}/jdk1.8.0_181
      export PATH=/${path_to_jdk_dir}/jdk1.8.0_181/bin:$PATH

      If you use the binary installation package (dmg or RPM), you may not need to manually configure environment variables. You can skip to the next step to check if Java is available.

  3. Check whether Java is installed:

    $ java -version
    Note

    The symbol $ is not required on Windows systems.

Install Apache Maven

Version requirements

SOFABoot requires Apache Maven version 3.2.5 or later.

Installation steps

  1. Go to the official Apache Maven website to download the installation package.

  2. Decompress the installation package file to the installation directory:

     $ unzip apache-maven-3.6.1-bin.zip

    or

     $ tar xzvf apache-maven-3.6.1-bin.tar.gz
  3. Configure environment variables:

    • Windows:

      • M2_HOME: The installation path of Maven.

      • PATH: Add a %M2_HOME%/bin path. Separate multiple paths with semicolons (;).

    • macOS and Linux: Example:

      export M2_HOME=/${path_to_maven_dir}/apache-maven-3.6.1
      export PATH=/${path_to_maven_dir}/apache-maven-3.6.1/bin:$PATH
  4. Check whether Maven is successfully installed in the new shell terminal:

    $ mvn -v

For more information, see Apache Maven documentation.

Modify the local configuration file of Maven

Modify steps

The JAR package of SOFABoot is not uploaded to the central repository of Maven. To download the dependent JAR packages when you build a project, you must:

  1. Locate the settings.xml file in the local Maven path. In different operating systems, you can refer to the following path to find.

    System global configuration file path:

    • Windows:$M2_HOME/conf/settings.xml

    • Linux or macOS: $M2_HOME/conf/settings.xml

      Note

      When both the user profile and the system profile are present, their contents are merged and the user settings.xml file dominates.

    User Profile Path:

    • Windows:${user.home}/.m2/settings.xml. Example:

      C:/Users/userName_XXX/.m2/settings.xml

      Note
      • The. m2 folder needs to comment out the <localRepository>D:/maven/repository</localRepository> in the system global configuration file settings.xml, and then execute mvn help:system commands are generated.

      • The settings.xml file is not generated by the system by default and needs to be manually copied.

    • Linux or macOS: ${user.home}/.m2/settings.xml. Example:

      /Users/userName_XXX/.m2/settings.xml

      Important

      On Linux or macOS systems, the. m2 directory may be hidden. macOS can Command + Shift + . to view; Linux can be viewed through the Ctrl + H.

  2. Click settings to download the Maven settings.xml file and copy it to the path in Step 1 or overwrite the settings.xml file in Step 1.

    Note

    • When you run the Maven command to create a project, the settings.xml file in the default Maven installation path is used by default. recommend, copy the downloaded settings.xml file to the. m2 directory. If there is a file with the same name in the. m2 directory, we recommend that you overwrite it.

    • If you want to use the Maven settings.xml in a custom path, we recommend that you specify it by mvn -s "file_path" in the Maven command. Example: mvn -s "C:/apache-maven-3.3.3/conf/settingsXXX.xml".

Configuration description

After the overwrite operation in Step 2, the information that has been configured in the settings.xml mainly includes the profile tag.

  • profile tag: used to configure some global information and its activation conditions, mainly including some warehouse tags, the content is as follows:

    <profile>
        <id>cloud-open-archetype</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
                <id>archetype</id><!-- Don't change this!  -->
                <url>http://mvn.cloud.alipay.com/nexus/content/groups/open</url>
                <releases>
                    <enabled>true</enabled>
                    <checksumPolicy>fail</checksumPolicy>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <checksumPolicy>warn</checksumPolicy>
                </snapshots>
            </repository>
        </repositories>
    </profile>