网站地址:http://www.pbteach.com/java/java_05_03/20210527/582534840956485632.html
操作报错启动的时候没有带参数启动
内容
点击创建项目
打开pom.xml文件添加apollo依赖,配置JDK为1.8
4.0.0 com.pbteach apollo-quickstart 1.0-SNAPSHOT 1.8 com.ctrip.framework.apollo apollo-client 1.1.0 org.slf4j slf4j-simple 1.7.28 org.apache.maven.plugins maven-compiler-plugin 8 8
自己测试的代码
public class ApolloTest {
public static void main(String[] args) {
Config appConfig = ConfigService.getAppConfig();
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
String property = appConfig.getProperty("sms.enable", null);
System.out.println(property);
}
}
}
输入key查询已存在的部门设置:organizations
代码实现
这个是 namespace 获取namespace 用的是 ConfigServer.getConfig
下边是account-service依赖,其它工程参考“资料”下的“微服务”。
4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.3.RELEASE com.pbteach account-service 0.0.1-SNAPSHOT 1.8 org.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-logging org.springframework.boot spring-boot-starter-log4j2 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-configuration-processor true com.ctrip.framework.apollo apollo-client 1.1.0



