使用携程apollo go版本app.properties的ip端口配置问题

2024-05-25 05:18

本文主要是介绍使用携程apollo go版本app.properties的ip端口配置问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

携程apollo, https://github.com/ctripcorp/apollo

背景

公司需要统一管理各个配置文件,而且apollo支持热发布以及不同环境不同集群配置等特征,所以选择使用apollo。

 

https://github.com/ctripcorp/apollo/wiki/Go%E3%80%81Python%E3%80%81NodeJS%E3%80%81PHP%E7%AD%89%E5%AE%A2%E6%88%B7%E7%AB%AF%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97

apollo的go客户端版本有3个。

 

3个版本的都进行了尝试。

zouyx/agollo的app.properties里面是namespacesName,是string类型

philchia/agollo的app.properties里面是namespaceNames,  是string类型的数组

shima-park/agollo的app.properties里面是namespaceNames,  是string类型的数组

app.properties如下

{"appId":"demo1","cluster":"default","namespaceNames":"apollo_demo","ip":"x.x.x.x:8070"
}

具体内容都是公司自己在apollo里面配置的,cluster默认就是default。

注意,我这里的ip的端口是8070,因为我让其他同事给我的地址就是http:/x.x.x.x:8070

导致我总是测试不通过的问题就在于这个ip的端口这里,这个端口应该是8080

感觉写的乱糟糟的,所以如果你在测试go版本的时候请记得把ip后面的端口修改为8080.

根据打印的日志可见请求这个ip会返回给我一个html,把这个html拿出来以后其实是类似apollo的登录的页面。

   而追踪代码发现,代码里面会把这个html转为json,进而转换为相应的结构体,由于这个html无法转为json,因此在

zouyx/agollo的app_config.go ##

syncServerIpListSuccessCallBack()这个方法总是报错,无法解析的json

 

在  philchia/agollo client.go中的##preload()

 

在shima-park/agollo 里面的agollo.go,报错如下:

 LoadConfigFromNonCache Error invalid character '<' looking for beginning of value

 

以上3个错误都是由于配置文件app.properties里面的ip配置的端口不对导致的。由于端口不对,返回的是html,不是json格式的数据,就会导致解析出错。

发现问题是测试了携程apollo里面给的【演示环境】https://github.com/ctripcorp/apollo

地址是:106.12.25.204:8070,可以根据给定的账号密码登录去建立测试的项目

但是配置文件里面写的是8080端口。

一定要注意端口

 

 

 

 

以下是测试的时候打印的Html

<!DOCTYPE html> 
<html lang="en" ng-app="login">
<head><meta charset="UTF-8"><title>Apollo配置中心</title><link rel="icon" href="./img/config.png"><link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css"><link rel="stylesheet" href="vendor/font-awesome.min.css"><style type="text/css">@import url(https://fonts.googleapis.com/css?family=Roboto:400,300,100,700,500);body {padding-top: 90px;background: #F7F7F7;color: #666666;font-family: 'Roboto', sans-serif;font-weight: 100;}body {width: 100%;background: -webkit-linear-gradient(left, #22d686, #24d3d3, #22d686, #24d3d3);background: linear-gradient(to right, #22d686, #24d3d3, #22d686, #24d3d3);background-size: 600% 100%;}.panel {border-radius: 5px;}label {font-weight: 300;}.panel-login {border: none;-webkit-box-shadow: 0px 0px 49px 14px rgba(188, 190, 194, 0.39);-moz-box-shadow: 0px 0px 49px 14px rgba(188, 190, 194, 0.39);box-shadow: 0px 0px 49px 14px rgba(188, 190, 194, 0.39);}.panel-login .checkbox input[type=checkbox] {margin-left: 0px;}.panel-login .checkbox label {padding-left: 25px;font-weight: 300;display: inline-block;position: relative;}.panel-login .checkbox {padding-left: 20px;}.panel-login .checkbox label::before {content: "";display: inline-block;position: absolute;width: 17px;height: 17px;left: 0;margin-left: 0px;border: 1px solid #cccccc;border-radius: 3px;background-color: #fff;-webkit-transition: border 0.15s ease-in-out, color 0.15s ease-in-out;-o-transition: border 0.15s ease-in-out, color 0.15s ease-in-out;transition: border 0.15s ease-in-out, color 0.15s ease-in-out;}.panel-login .checkbox label::after {display: inline-block;position: absolute;width: 16px;height: 16px;left: 0;top: 0;margin-left: 0px;padding-left: 3px;padding-top: 1px;font-size: 11px;color: #555555;}.panel-login .checkbox input[type="checkbox"] {opacity: 0;}.panel-login .checkbox input[type="checkbox"]:focus + label::before {outline: thin dotted;outline: 5px auto -webkit-focus-ring-color;outline-offset: -2px;}.panel-login .checkbox input[type="checkbox"]:checked + label::after {font-family: 'FontAwesome';content: "\f00c";}.panel-login > .panel-heading .tabs {padding: 0;}.panel-login h2 {font-size: 20px;font-weight: 300;margin: 30px;}.panel-login > .panel-heading {color: #848c9d;background-color: #e8e9ec;border-color: #fff;text-align: center;border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;border-top-left-radius: 0px;border-top-right-radius: 0px;border-bottom: 0px;padding: 0px 15px;}.panel-login .form-group {padding: 0 30px;}.panel-login > .panel-heading .login {padding: 20px 30px;border-bottom-leftt-radius: 5px;}.panel-login > .panel-heading .register {padding: 20px 30px;background: #2d3b55;border-bottom-right-radius: 5px;}.panel-login > .panel-heading a {text-decoration: none;color: #666;font-weight: 300;font-size: 16px;-webkit-transition: all 0.1s linear;-moz-transition: all 0.1s linear;transition: all 0.1s linear;}.panel-login > .panel-heading a#register-form-link {color: #fff;width: 100%;text-align: right;}.panel-login > .panel-heading a#login-form-link {width: 100%;text-align: left;}.panel-login input[type="text"], .panel-login input[type="email"], .panel-login input[type="password"] {height: 45px;border: 0;font-size: 16px;-webkit-transition: all 0.1s linear;-moz-transition: all 0.1s linear;transition: all 0.1s linear;-webkit-box-shadow: none;box-shadow: none;border-bottom: 1px solid #e7e7e7;border-radius: 0px;padding: 6px 0px;}.panel-login input:hover,.panel-login input:focus {outline: none;-webkit-box-shadow: none;-moz-box-shadow: none;box-shadow: none;border-color: #ccc;}.btn-login {background-color: #E8E9EC;outline: none;color: #2D3B55;font-size: 14px;height: auto;font-weight: normal;padding: 14px 0;text-transform: uppercase;border: none;border-radius: 0px;box-shadow: none;}.btn-login:hover,.btn-login:focus {color: #fff;background-color: #2D3B55;}.forgot-password {text-decoration: underline;color: #888;}.forgot-password:hover,.forgot-password:focus {text-decoration: underline;color: #666;}.btn-register {background-color: #E8E9EC;outline: none;color: #2D3B55;font-size: 14px;height: auto;font-weight: normal;padding: 14px 0;text-transform: uppercase;border: none;border-radius: 0px;box-shadow: none;}.btn-register:hover,.btn-register:focus {color: #fff;background-color: #2D3B55;}</style>
</head>
<body><div class="container" ng-controller="LoginController"><div class="row"><div class="col-md-6 col-md-offset-3"><div class="panel panel-login"><div class="panel-body"><div class="row"><div class="col-lg-12"><form id="login-form" action="/signin" method="post" role="form" style="display: block;"><p class="text-center"><img src="img/logo-detail.png" style="width: 500px;"></p><div class="form-group"><input type="text" name="username" tabindex="1" class="form-control"placeholder="Username" value=""></div><div class="form-group"><input type="password" name="password" tabindex="2"class="form-control" placeholder="Password"></div><div class="form-group" style="color: red"><small ng-bind="info"></small></div><div class="col-xs-12 form-group pull-right"><input type="submit" name="login-submit" id="login-submit" tabindex="4"class="form-control btn btn-login" value="登录"></div></form></div></div></div></div></div></div>
</div>
<!-- jquery.js -->
<script src="vendor/jquery.min.js" type="text/javascript"></script>
<!-- bootstrap.js -->
<script src="vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script><!--angular-->
<script src="vendor/angular/angular.min.js"></script>
<script src="vendor/angular/angular-resource.min.js"></script>
<script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script>
<script src="vendor/angular/loading-bar.min.js"></script><script type="application/javascript" src="scripts/app.js"></script>
<script type="application/javascript" src="scripts/AppUtils.js"></script>
<script type="application/javascript" src="scripts/directive/directive.js"></script>
<script type="application/javascript" src="scripts/controller/LoginController.js"></script><script type="application/javascript">$(function () {$('#login-form-link').click(function (e) {$("#login-form").delay(100).fadeIn(100);$("#register-form").fadeOut(100);$('#register-form-link').removeClass('active');$(this).addClass('active');e.preventDefault();});$('#register-form-link').click(function (e) {$("#register-form").delay(100).fadeIn(100);$("#login-form").fadeOut(100);$('#login-form-link').removeClass('active');$(this).addClass('active');e.preventDefault();});});</script>
</body>
</html>

 

这篇关于使用携程apollo go版本app.properties的ip端口配置问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1000585

相关文章

使用Python删除Excel中的行列和单元格示例详解

《使用Python删除Excel中的行列和单元格示例详解》在处理Excel数据时,删除不需要的行、列或单元格是一项常见且必要的操作,本文将使用Python脚本实现对Excel表格的高效自动化处理,感兴... 目录开发环境准备使用 python 删除 Excphpel 表格中的行删除特定行删除空白行删除含指定

深入理解Go语言中二维切片的使用

《深入理解Go语言中二维切片的使用》本文深入讲解了Go语言中二维切片的概念与应用,用于表示矩阵、表格等二维数据结构,文中通过示例代码介绍的非常详细,需要的朋友们下面随着小编来一起学习学习吧... 目录引言二维切片的基本概念定义创建二维切片二维切片的操作访问元素修改元素遍历二维切片二维切片的动态调整追加行动态

prometheus如何使用pushgateway监控网路丢包

《prometheus如何使用pushgateway监控网路丢包》:本文主要介绍prometheus如何使用pushgateway监控网路丢包问题,具有很好的参考价值,希望对大家有所帮助,如有错误... 目录监控网路丢包脚本数据图表总结监控网路丢包脚本[root@gtcq-gt-monitor-prome

Python通用唯一标识符模块uuid使用案例详解

《Python通用唯一标识符模块uuid使用案例详解》Pythonuuid模块用于生成128位全局唯一标识符,支持UUID1-5版本,适用于分布式系统、数据库主键等场景,需注意隐私、碰撞概率及存储优... 目录简介核心功能1. UUID版本2. UUID属性3. 命名空间使用场景1. 生成唯一标识符2. 数

SpringBoot中如何使用Assert进行断言校验

《SpringBoot中如何使用Assert进行断言校验》Java提供了内置的assert机制,而Spring框架也提供了更强大的Assert工具类来帮助开发者进行参数校验和状态检查,下... 目录前言一、Java 原生assert简介1.1 使用方式1.2 示例代码1.3 优缺点分析二、Spring Fr

Android kotlin中 Channel 和 Flow 的区别和选择使用场景分析

《Androidkotlin中Channel和Flow的区别和选择使用场景分析》Kotlin协程中,Flow是冷数据流,按需触发,适合响应式数据处理;Channel是热数据流,持续发送,支持... 目录一、基本概念界定FlowChannel二、核心特性对比数据生产触发条件生产与消费的关系背压处理机制生命周期

java使用protobuf-maven-plugin的插件编译proto文件详解

《java使用protobuf-maven-plugin的插件编译proto文件详解》:本文主要介绍java使用protobuf-maven-plugin的插件编译proto文件,具有很好的参考价... 目录protobuf文件作为数据传输和存储的协议主要介绍在Java使用maven编译proto文件的插件

SpringBoot线程池配置使用示例详解

《SpringBoot线程池配置使用示例详解》SpringBoot集成@Async注解,支持线程池参数配置(核心数、队列容量、拒绝策略等)及生命周期管理,结合监控与任务装饰器,提升异步处理效率与系统... 目录一、核心特性二、添加依赖三、参数详解四、配置线程池五、应用实践代码说明拒绝策略(Rejected

C++ Log4cpp跨平台日志库的使用小结

《C++Log4cpp跨平台日志库的使用小结》Log4cpp是c++类库,本文详细介绍了C++日志库log4cpp的使用方法,及设置日志输出格式和优先级,具有一定的参考价值,感兴趣的可以了解一下... 目录一、介绍1. log4cpp的日志方式2.设置日志输出的格式3. 设置日志的输出优先级二、Window

Ubuntu如何分配​​未使用的空间

《Ubuntu如何分配​​未使用的空间》Ubuntu磁盘空间不足,实际未分配空间8.2G因LVM卷组名称格式差异(双破折号误写)导致无法扩展,确认正确卷组名后,使用lvextend和resize2fs... 目录1:原因2:操作3:报错5:解决问题:确认卷组名称​6:再次操作7:验证扩展是否成功8:问题已解