springcloud费话之配置中心server修改

目录:

springcloud费话之Eureka基础

springcloud费话之Eureka集群

springcloud费话之Eureka服务访问(restTemplate)

springcloud费话之Eureka接口调用(feign)

springcloud费话之断路器(hystrix in feign)

springcloud费话之配置中心基础(SVN)

springcloud费话之配置中心客户端(SVN)

springcloud的配置中心,即config-server的端口只能之8888的问题比较恶心

原因在于spring代码中写死了每一个获取配置的客户端,都是向8888请求,因此问题出在客户端上

但是服务端也要进行一定程度的修改

思路:

修改config服务端端口,改为非8888端口

修改config客户端获取配置的方式,从固定的ip和端口,修改为通过eureka注册中心,通过注册的名称来获取

将config的服务端添加进eureka注册中心

实际代码如下:

修改config-server的配置如下:

1server: 2 port: 9999 3 tomcat: 4 max-threads: 10000 5 max-connections: 20000 6 7eureka: 8 client: 9 serviceUrl: 10 defaultZone: http://localhost:10086/eureka/ 11 12spring: 13 application: 14 name: config-server 15 profiles: 16 active: subversion 17 cloud: 18 config: 19 server: 20 svn: 21 uri: https://xxxxxx/svn/liuyuhang_FM/configCenter/ 22 username: liuyuhang 23 password: xxxxxx 24 search-paths: null 25 default-label: testConfig 26      basedir: /data

修改config-client配置如下:

1server: 2 port: 8889 3 tomcat: 4 max-threads: 10000 5 max-connections: 20000 6spring: 7 application: 8 name: config-client 9 cloud: 10 config: 11 discovery: 12 enabled: true 13 service-id: config-server 14 15 profiles: 16 active: dev 17 18eureka: 19 client: 20 serviceUrl: 21 defaultZone: http://localhost:10086/eureka/

注意spring的application的name一定要正确

注意config-client中的discovery中,要enable为true,表示可以被发现

然后指定service-id,来代替之前的uri配置即可

因为config-server中添加了eureka作为客户端,pom需要引入eureka的内容,节选如下:

1     <!-- eureka server的jar, 作为client也需要 --> 2 <dependency> 3 <groupId>org.springframework.cloud</groupId> 4 <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> 5 </dependency> 6 <!-- eureka client的jar --> 7 <dependency> 8 <groupId>org.springframework.cloud</groupId> 9 <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>

添加了以后,config-server还需要对启动入口添加eureka的client的注解,节选代码如下:

1@SpringBootApplication(exclude = DataSourceAutoConfiguration.class) 2@EnableEurekaClient 3@EnableConfigServer 4public class ConfigApplication extends SpringBootServletInitializer { 5 public static void main(String[] args) { 6 SpringApplication.run(ConfigApplication.class, args); 7 } 8}

以上~

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

Java爬虫之JSoup使用教程

title:Java爬虫之JSoup使用教程date:201812248:00:000800update:201812248:00:000800author:mecover:https://imgblog.csdnimg.cn/20181224144920712(https://www.oschin

KVM调整cpu和内存

一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid