栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Apollo全部

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Apollo全部

网站地址: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
        
 ​
    
 ​
 































转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/988482.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号