SpringCloud的学习记录(3)
这一章节讲搭建config-server的项目.
在我们生成的Demo项目上右键点击New->Module->spring Initializr, 然后next, 填写Group和Artifact等信息,
这里Artifact填写configserver, 再次next,
这里选择的Web下的web和Cloud Discovery下的Eureka Discovery, 同时选择Cloud Config下的Config Server.
最后在Module Name中填写config-server.
生成的pom.xml文件如下:
在src->main->resources下建立application.yml文件, 内容如下
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/ // 这里依然是注册到eureka-server中
server:
port: 8765
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: https://github.com/xxx 你的git仓库地址
searchPaths: repos
username: 你的git用户名
password: 你的git密码
label: master
在ConfigServerApplication.java里的内容如下, 要加上@EnableConfigServer这个注解
package com.xum.configserver; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.config.server.EnableConfigServer; @EnableEurekaClient
@EnableConfigServer
@SpringBootApplication
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
这样Config-server项目搭建完成,
用Run DashBoard顺序启动如下项目:
1. eureka-server
2. config-server
3. eureka-client
然后再次运行上一章节的几条api就可以看到效果了
先在浏览器中输入http://localhost:8762/testone/test, 显示如下
port是eureka-client的端口
然后在浏览器中输入http://localhost:8762/testone/config, 显示如下
port是eureka-client的端口, message和foo是从git仓库中获取的, 是通过config-server项目获取的.
下一章节讲如何在改变git上的值后, eureka-client能及时的更新.
SpringCloud的学习记录(3)的更多相关文章
- SpringCloud的学习记录(1)
最近一段时间重新学习一边SpringCloud(有半年不用了),这里简单记录一下. 我用的是IntelliJ IDEA开发工具, SpringBoot的版本是2.1.3.RELEASE. 1. 构建M ...
- SPRINGCLOUD 开发学习记录
一个简单的微服务系统:服务注册和发现,服务消费,负载均衡,断路器,智能路由,配置管理 服务注册中心: eureka是一个高可用组件,没有后端缓存,每一个实例注册后向注册中心发送心跳,默认情况下,eru ...
- SpringCloud的学习记录(8)
这一章节讲zipkin-server. 在我们生成的Demo项目上右键点击New->Module->spring Initializr, 然后next, 填写Group和Artifact等 ...
- SpringCloud的学习记录(7)
这一章节讲zuul的使用. 在我们生成的Demo项目上右键点击New->Module->spring Initializr, 然后next, 填写Group和Artifact等信息, 这里 ...
- SpringCloud的学习记录(6)
这一章节讲fegin的使用. 在我们生成的Demo项目上右键点击New->Module->spring Initializr, 然后next, 填写Group和Artifact等信息, 这 ...
- SpringCloud的学习记录(5)
这一章节讲如何使用ribbon和hystrix. 在我们生成的Demo项目上右键点击New->Module->spring Initializr, 然后next, 填写Group和Arti ...
- SpringCloud的学习记录(2)
这一章节主要讲如何搭建eureka-client项目. 在我们生成的Demo项目上右键点击New->Module->spring Initializr, 然后next, 填写Group和A ...
- SpringCloud的学习记录(4)
本篇基于上一篇写的, 在git上更改配置后, eureka-client如何更新. 我们只需要在配置文件中配置 spring-cloud-starter-bus-amqp; 这就是说我们需要装rabb ...
- SpringCloud基础教程学习记录
这个学习记录是学习自翟永超前辈的SpringCloud的基础教程. 自己写这个教程的目的主要是在于,想要更凝练总结一些其中的一些实用点,顺便做个汇总,这样自己在复习查看的时候更加方便,也能顺着自己的思 ...
随机推荐
- 「产品经理全连接系列2」企业如何开展敏捷或DevOps的研发变革
大家好,我是华为云的产品经理 恒少: 作为布道师和产品经理,出差各地接触客户是常态,经常和华为云的客户交流.布道.技术沙龙,但是线下交流,覆盖的用户总还是少数. 我希望可以借线上的平台,和用户持续交流 ...
- JDK 1.6.0_45 下载
Java SE Development Kit 6u45 Product / File Description File Size Download password Linux x86 65.46 ...
- kuangbin专题十六 KMP&&扩展KMP HDU3746 Cyclic Nacklace
CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, ...
- 前端优化系列之一:dns预获取 dns-prefetch 提升页面载入速度
问题:怎么做到dns域解析? 用于优化网站页面的图片 问题:怎么提升网站性能? dns域解析,是提升网站的一个办法. DNS Prefetch,即DNS预获取,是前端优化的一部分. 一般来 ...
- [JavaScript] New-Agnostic Constructor Pattern
function User (name, password) { var self = this instanceof User ? this : new User(); if (name != nu ...
- 钉钉jsapi免登获取code中,出现对应企业没有某域名微应用
在使用jsapi中.出现 {"errorMessage":"对应企业没有某域名微应用",:"errorCode":"3" ...
- KindEditor的参考文献
转自:http://www.cnblogs.com/wupeiqi/articles/6307554.html
- Django-redis 缓存
存在内存中 Diango-redis redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集 ...
- css过渡transition
定义 过渡transition是一个复合属性,包括transition-property.transition-duration.transition-timing-function.transiti ...
- 关于 java中的SecureRandom在linux中每次生成不同结果
使用AES算法的时候,会发现下面的代码在windows每次产生确定的结果,但Linux就不同,导致无法正确解密 public static String encrypt(String content, ...