Giter VIP home page Giter VIP logo

cloud-demo's Introduction

学习笔记

创建微服务案例

  1. 新建maven项目,删除多余的东西;在此基础上,新建两个module,用spring初始化,名为order-service、user-service。
  2. 在两个模块内创建实体,配置mybatis,配置端口号,数据库,写一个简单的查询。
  3. 启动两个服务,可以各自访问各自的请求。

远程调用

  1. 在需要调用远程服务的启动类上面注入ResTemplate类,在服务类声明ResTemplate,调用远程接口的url,设置返回对象。

Eureka

  1. 客户端会每个三十秒想服务端发送心跳。
  2. 引入服务端依赖,在serve端加入eureka的注解,yml文件中配置eureka的地址服务名。
  3. 引入客户端依赖,yml文件中配置。

负载均衡

  1. 更改url的主机端口为服务名,在ResTemplate中加入负载均衡的注解。
  2. 当有多个集群时,可以互相分摊访问。

Ribbon负载均衡

  1. 全局配置
  2. 服务配置 yml

nacos

  1. 服务的注册和发现,分布式配置。
  2. nacos.io 官网,下载,启动。
  3. 启动命令 · Windows安装命令
startup.cmd -m standalone
  1. 账号密码都是 nacos

Feign

  1. 比ResTemplate更优雅,声明式
  2. 引入依赖,启动类加上注解
  3. 创建client类,加注解,写方法。
  4. feign 的配置。可以 yml 配置,也可以bean配置;bean配置之后可以加在启动类,这是全局;也可以加在client类上,是局部。
  5. feign的性能优化。连接池配置。引入依赖,配置连接池yml。
  6. feign的最佳实践。方式一,继承。方式二,抽取,公共模块。

gateway

  1. 网关有两个,zuul较早,gateway比较新。
  2. 新建模块,引入依赖,创建启动类。配置yml
  3. 断言工厂
  4. 过滤器工厂

cloud-demo's People

Contributors

reye0 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.