Obtaining the MRS Application Development Sample Project
Process for Building an MRS Sample Project
Building a sample project includes the following operations:
- Download the Maven project source code and configuration files of the sample project. For details, see Obtaining the MRS Sample Project.
- Configure the Maven mirror repository of the SDK in Huawei Mirrors. For details, see Configuring Huawei Open-Source Mirrors.
- Build a complete Maven project based on user requirements.
Obtaining the MRS Sample Project
- For MRS 1.8.x, you can download sample projects at https://github.com/huaweicloud/huaweicloud-mrs-example/tree/mrs-1.8.
- For MRS 1.9.x, you can download sample projects at https://github.com/huaweicloud/huaweicloud-mrs-example/tree/mrs-1.9.
- For MRS 2.0.x and 2.1.x, you can download sample projects at https://github.com/huaweicloud/huaweicloud-mrs-example/tree/mrs-2.0.
- For MRS 3.0.2, you can download sample projects at https://github.com/huaweicloud/huaweicloud-mrs-example/tree/mrs-3.0.2.
- For MRS 3.1.0, you can download sample projects at https://github.com/huaweicloud/huaweicloud-mrs-example/tree/mrs-3.1.0.
- For MRS 3.1.5, you can download sample projects at https://github.com/huaweicloud/huaweicloud-mrs-example/tree/mrs-3.1.5.
Download the package to the local host and decompress it to obtain the sample code of the components.
For details about how to obtain the sample project of MRS 3.1.2-LTS, see Obtaining Sample Projects from Huawei Mirrors.
Configuring Huawei Open-Source Mirrors
Huawei provides Huawei Mirrors for you to download all dependency JAR files of sample projects. However, you need to download the rest dependency open-source JAR files from the Maven central repository or other custom repository address.
Before using a development tool to download the dependency JAR files in the local environment, ensure that the following conditions are met:
- The local network is normal.
Uses a browser and visit Huawei Mirrors to check whether the website can be accessed. If the access is abnormal, connect the local network.
- The proxy is disabled for the development tool.
Take the IntelliJ IDEA development tool of version 2020.2 as an example. Choose File > Settings > Appearance & Behavior > System Settings > HTTP Proxy, select No proxy, and click OK to save the configuration.
Perform the following steps to configure the open-source mirror warehouse.
- Check that JDK 1.8 or later and Maven 3.0 or later have been installed.
- Configure the Maven configuration file.
- To overwrite the Maven configuration file, choose Huawei SDK > HuaweiCloud SDK at Huawei Mirrors, download the settings.xml file, and overwrite the <Maven installation directory>/conf/settings.xml file with the downloaded file.
- (Optional) If you do not want to overwrite the Maven configuration file, manually modify the settings.xml configuration file or the pom.xml file of the component sample project to configure the mirror repository address. The configuration methods are as follows:
- Configuration method 1: Modify the settings.xml configuration file.
Add the following open-source mirror repository address to mirrors in the settings.xml configuration file.
<mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <url>https://repo1.maven.org/maven2/</url> </mirror>
Add the following mirror repository address to profiles in the settings.xml configuration file.
<profile> <id>huaweicloudsdk</id> <repositories> <repository> <id>huaweicloudsdk</id> <url>https://repo.huaweicloud.com/repository/maven/huaweicloudsdk/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> </profile>
Add the following mirror repository address to the activeProfiles node in the settings.xml file.
<activeProfile>huaweicloudsdk</activeProfile>
- Huawei Mirrors does not provide third-party open-source JAR files. After configuring Huawei open-source mirrors, you need to separately configure third-party Maven mirror repository address.
- When using the IntelliJ IDEA development tool, you can choose File > Settings > Build, Execution, Deployment > Build Tools > Maven to view the directory where the settings.xml file is stored.
- Configuration method 2: Modify the pom.xml configuration file.
Add the following mirror repository address directly to the pom.xml file in the secondary development sample project.
<repositories> <repository> <id>huaweicloudsdk</id> <url>https://mirrors.huaweicloud.com/repository/maven/huaweicloudsdk/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> <repository> <id>central</id> <name>Maven Central</name> <url>https://repo1.maven.org/maven2/</url> </repository> </repositories>
- Configuration method 1: Modify the settings.xml configuration file.
- Configure the default Maven code and JDK. Add the following information to profiles in the settings.xml configuration file:
<profile> <id>JDK1.8</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.8</jdk> </activation> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <maven.compiler.encoding>UTF-8</maven.compiler.encoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> </properties> </profile>
Feedback
Was this page helpful?
Provide feedbackThank 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