window下使用

服务端使用
服务端代码下载链接
​apollo-quick-start-1.6.1.zip​​

配置中心使用Apollo使用_客户端

配置中心使用Apollo使用_服务端_02


git 运行

配置中心使用Apollo使用_服务端_03


​ http://localhost:8070/登录​配置中心使用Apollo使用_客户端_04

新建客户端



客户端使用

pom.xml

<!-- apollo 携程apollo配置中心框架 -->
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-core</artifactId>
<version>1.6.0</version>
</dependency>

配置中心使用Apollo使用_客户端_05

app.properties

app.id=12355454

apollo-env.properties

local.meta=http://localhost:8080
dev.meta=http://localhost:8080
fat.meta=${fat_meta}
uat.meta=${uat_meta}
lpt.meta=${lpt_meta}
pro.meta=${pro_meta}

重点:

配置中心使用Apollo使用_服务端_06


server.properties

env=DEV

CloudTestApplication.java

@Configuration
@EnableApolloConfig
@SpringBootApplication
@EnableAutoConfiguration

public class CloudTestApplication {

public static void main(String[] args) {
SpringApplication.run(CloudTestApplication.class, args);
}

}

TestController.java

@RestController
@EnableApolloConfig({"mstest"})
public class TestController {
@Value("${server.port}")
int port;
@Value("${mstest.port:1234}")
private int msPort;

@RequestMapping("hello")
public String hello() {
return msPort + "";
}


}