1......   概念: 

            Eureka   是Netflix开发的服务发现框架,本身是一个基于REST的服务,

           主要用于定位运行在AWS域中的中间层服务,以达到负载均衡和中间层服务故障转移的目的。SpringCloud将它集成在其子项目spring-cloud-netflix中,以实现SpringCloud的服务发现功能。

2.....    基于上次代码:

              依次为基础进行 添加 eureka 服务与 发现代码

3.....  provider 类 的 resources / application.yml 加上代码    

 1 server:
 2   port: 8001
 3 mybatis:
 4   config-location: classpath:mybatis/mybatis.cfg.xml #mybatis 配置文件路径
 5   type-aliases-package: com.wsc.core.pojo # entity别名类所在包
 6   mapper-locations: mybatis/mapper/*.xml    # mapper映射文件
 7 spring:
 8   application:
 9     name: microserver-product #这个很重要,这在以后的服务与服务之间相互调用一般都是根据这个name
10   datasource:
11     type: com.alibaba.druid.pool.DruidDataSource
12     driver-class-name: com.mysql.cj.jdbc.Driver
13     url: jdbc:mysql://127.0.0.1:3306/springcloud_db01?serverTimezone=GMT%2B8
14     password: wsc
15     username: root
16     dbcp2:
17       min-idle: 5                         # 数据库连接池的最小维持连接数
18       initial-size: 5                     # 初始化连接数
19       max-total: 5                        # 最大连接数
20       max-wait-millis: 150                                    # 等待连接获取的最大超时时间
21 
22 eureka:
23   client:
24     register-with-eureka: true             #服务注册开关
25     fetch-registry: true                  #服务发现开关
26     service-url:
27       defaultZone: http://localhost:6001/eureka # 1 显示主机名
28   instance:
29     instanceId: ${spring.application.name}.${server.port} #  2   指定实例ID 不显示主机名
30     preferipAddress: true
View Code

相关文章:

  • 2021-11-26
  • 2021-12-27
  • 2021-04-16
  • 2021-08-07
猜你喜欢
  • 2022-03-01
  • 2021-06-05
  • 2021-10-07
  • 2021-09-06
  • 2021-04-28
  • 2021-07-12
相关资源
相似解决方案