使用 Pandora Boot 开发 HSF 应用前,需要先配置 SAE 的私服地址和轻量级配置及注册中心。
背景信息
- 目前 Spring Cloud for Aliware 的第三方包只发布在 SAE 的私服中,所以需要在 Maven 中配置 SAE 的私服地址。
- 本地开发调试时,需要启动轻量级配置注册中心。轻量级配置及注册中心包含了服务发现和配置管理功能。
在 Maven 中配置 SAE 的私服地址
说明 Maven 要求 3.x 及后续版本。在 Maven 配置文件 settings.xml 中加入 SAE 私服地址。
- 请参考如下示例,在 Maven 所使用的配置文件(一般为~/.m2/settings.xml)中添加 SAE 的私服配置。
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>edas.oss.repo</id>
<repositories>
<repository>
<id>edas-oss-central</id>
<name>taobao mirror central</name>
<url>http://edas-public.oss-cn-hangzhou.aliyuncs.com/repository</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>edas-oss-plugin-central</id>
<url>http://edas-public.oss-cn-hangzhou.aliyuncs.com/repository</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
<activeProfile>edas.oss.repo</activeProfile>
</activeProfiles>
- 在命令行执行命令 mvn help:effective-settings,验证配置是否成功。
- 无报错,表明 setting.xml 文件格式没问题。
- profiles 中包含 edas.oss.repo 这个 profile,表明私服已经配置到 profiles 中。
- activeProfiles 中包含 edas.oss.repo 属性,表明 edas.oss.repo 私服已激活。
说明 如果在命令行执行 Maven 打包命令无问题,IDE 仍无法下载依赖,请关闭 IDE 重新打开再尝试,或自行查找 IDE 配置 Maven 的相关资料。