SpringCloud 学习总结(思维导图)

SpringCloud 学习总结(思维导图)_第1张图片

详细内容

  • SpringCloud 学习总结(一)
  • SpringCloud 学习总结(二)

相关配置信息

工程目录:
在这里插入图片描述
关于application.yml中的配置:

服务提供者:provider

server:
  port: 8081

#数据库连接信息
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/boot?useSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8
    username: root
    password: 123456
  application:
    name: service-provider  #将来会作为微服务的名称

#配置mybatis信息,pojo别名扫描包
mybatis:
  type-aliases-package: com.ly.domain
eureka:
  client:
    service-url:
      defaultZone: http://localhost:10086/eureka
    register-with-eureka: true  #默认值为true,服务提供方启动时,会检测该参数是否为true,true-注册给eureka
  instance:
    lease-renewal-interval-in-seconds: 5 #心跳时间
    lease-expiration-duration-in-seconds: 15 #过期时间

服务调用者:consumer

server:
  port: 8088
spring:
  application:
    name: service-consumer  #将来会作为微服务的名称
eureka:
  client:
    service-url:
      defaultZone: http://localhost:10086/eureka
    fetch-registry: true  #是否拉取服务,默认为true
    registry-fetch-interval-seconds: 5 #拉取服务的间隔时间
service-provider:
  ribbon:
    NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule
hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 6000 #设置hystrix的超时时间为6000ms

feign:
  hystrix:
    enabled: true #开启Feign的熔断功能

Eureka服务注册中心:

server:
  port: 10086
spring:
  application:
    name: ly-eureka #将来会作为微服务名称注入到eureka容器

eureka:
  client:
    service-url:
      defaultZone: http://localhost:${
     server.port}/eureka

  #server:
    #eviction-interval-timer-in-ms: 5000 #失效剔除时间,单位毫秒
    #enable-self-preservation: false  #关闭自我保护状态

Zuul网关:

server:
  port: 10010
spring:
  application:
    name: ly-zuul

#zuul:  #路由配置方式1
  #routes:
    #service-provider:
      #path: /service-provider/**
      #url: http://localhost:8081

#zuul:  #路由配置方式2
  #routes:
    #service-provider:
      #path: /service-provider/**    
      #serviceId: service-provider

zuul:   #路由配置方式3,推荐
  routes:
      service-provider: /provider/**
      service-consumer: /consumer/**
  prefix: /api

eureka:
  client:
    service-url:
      defaultZone: http://localhost:10086/eureka

启动器相关:



<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-webartifactId>
dependency>


<dependency>
    <groupId>org.mybatis.spring.bootgroupId>
    <artifactId>mybatis-spring-boot-starterartifactId>
    <version>2.1.4version>
dependency>

 
<dependency>
    <groupId>tk.mybatisgroupId>
    <artifactId>mapper-spring-boot-starterartifactId>
    <version>2.0.4version>
dependency>


<dependency>
    <groupId>mysqlgroupId>
    <artifactId>mysql-connector-javaartifactId>
    <version>8.0.11version>
    <scope>runtimescope>
dependency>


<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-jdbcartifactId>
dependency>


<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-actuatorartifactId>
dependency>


<dependency>
    <groupId>org.springframework.cloudgroupId>
    <artifactId>spring-cloud-starter-netflix-eureka-serverartifactId>
dependency>


<dependency>
    <groupId>org.springframework.cloudgroupId>
    <artifactId>spring-cloud-starter-netflix-eureka-clientartifactId>
    <version>2.0.0.RELEASEversion>
dependency>


<dependency>
    <groupId>org.springframework.cloudgroupId>
    <artifactId>spring-cloud-starter-netflix-zuulartifactId>
dependency>


<dependency>
    <groupId>org.springframework.cloudgroupId>
    <artifactId>spring-cloud-starter-netflix-hystrixartifactId>
dependency>


<dependency>
    <groupId>com.github.pagehelpergroupId>
    <artifactId>pagehelper-spring-boot-starterartifactId>
dependency>


<dependency>
    <groupId>org.springframework.cloudgroupId>
    <artifactId>spring-cloud-starter-openfeignartifactId>
dependency>



<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-testartifactId>
    <scope>testscope>
    <exclusions>
        <exclusion>
            <groupId>org.junit.vintagegroupId>
            <artifactId>junit-vintage-engineartifactId>
        exclusion>
    exclusions>
dependency>

你可能感兴趣的:(Spring,Cloud,spring,cloud)