更新时间:2024-05-27 GMT+08:00
获取MRS应用开发样例工程
MRS样例工程构建流程
MRS服务样例工程构建流程包括三个主要步骤:
样例工程获取地址
- 华为云MRS服务1.8.x版本的样例工程下载地址为:https://github.com/huaweicloud/huaweicloud-mrs-example/tree/mrs-1.8。
- 华为云MRS服务1.9.x版本的样例工程下载地址为:https://github.com/huaweicloud/huaweicloud-mrs-example/tree/mrs-1.9。
- 华为云MRS服务2.1.x版本的样例工程下载地址为:https://github.com/huaweicloud/huaweicloud-mrs-example/tree/mrs-2.1。
图1 样例代码下载
配置华为开源镜像仓
华为云提供开源镜像站,MRS服务样例工程依赖的jar包都需要在华为开源镜像站下载,剩余所依赖的开源jar包请直接从Maven中央库下载。
华为云开源镜像配置方式如下所示:
- 使用前请确保您已安装JDK 1.8及以上版本和Maven 3.0及以上版本。
- 访问并登录华为开源镜像站。
- 下载华为开源镜像站提供的“settings.xml”文件,覆盖至“<本地Maven安装目录>/conf/settings.xml”文件即可。
若无法直接下载,在华为开源镜像站搜索并单击名称为“HuaweiCloud SDK”的版块,按照页面弹出的设置方法进行操作。
- 参考以下方法手动修改“setting.xml”配置文件或者组件样例工程中的“pom.xml”文件,配置镜像仓地址。
- 配置方法一:
手动在setting.xml配置文件的mirrors节点中添加开源镜像仓地址:
<mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <url>https://repo1.maven.org/maven2/</url> </mirror>
在setting.xml配置文件的profiles节点中添加如下镜像仓地址:
<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>
在setting.xml配置文件的activeProfiles节点中添加如下镜像仓地址:
<activeProfile>huaweicloudsdk</activeProfile>
华为云开源镜像站不提供第三方开源jar包下载,请配置华为云开源镜像后,额外配置第三方Maven镜像仓库地址。
- 配置方法二:
在二次开发工程样例工程中的pom.xml文件添加如下镜像仓地址:
<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>Mavn Centreal</name> <url>https://repo1.maven.org/maven2/</url> </repository> </repositories>
- 配置方法一: