1...... 概念:
Eureka 是Netflix开发的服务发现框架,本身是一个基于REST的服务,
主要用于定位运行在AWS域中的中间层服务,以达到负载均衡和中间层服务故障转移的目的。SpringCloud将它集成在其子项目spring-cloud-netflix中,以实现SpringCloud的服务发现功能。
2..... 基于上次代码:
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