SpringBoot配置搭建Apollo
1.windows环境下apollo单机搭建
环境准备:JDK1.8,mysql 5.7.6+, git-2.21.0(执行apollo的启动脚本) https://git-scm.com/downloads、apollo安装包(官网为我们准备了 Quick Start 安装包。大家只需要下载到本地,就可以直接使用,免去了编译、打包过程。大家可以到github下载,也可以通过百度云盘下载)
2.apollo配置具体过程参考文献:springboot2.0从apollo读取配置
3.注意使用:切记mysql服务要启动,8080、8070、8090这三个端口不要被占用,也不要随意改动这三个端口
4.SpringBoot Apollo配置依赖:
<apollo-client.version>1.1.0</apollo-client.version>
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>${apollo-client.version}</version>
</dependency>
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-core</artifactId>
<version>${apollo-client.version}</version>
</dependency>
5.环境切分配置pom.xml:
<profiles>
<profile> <!--开发环境-->
<id>dev</id>
<properties>
<profiles.active>dev</profiles.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile> <!--准生产环境-->
<id>uat</id>
<properties>
<profiles.active>uat</profiles.active>
</properties>
</profile>
<profile> <!--生产环境-->
<id>pro</id>
<properties>
<profiles.active>pro</profiles.active>
</properties>
</profile>
</profiles>
6.[application.yml]配置:
server:
port: 9099
#spring:
# application:
# name: apolloDeno
# Apollo配置ID
app:
id: 110
# set apollo meta server address, adjust to actual address if necessary
apollo:
meta: ip + port
bootstrap:
enabled : true
7.参考文献:Spring Boot 2.0 整合携程Apollo配置中心