<!--eureka-server-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
server:
port: 7001
eureka:
instance:
hostname: localhost #服务端的实例名称
client:
#false表示不向服务器注册自己
register-with-eureka: false
#false表示自己就是注册中心 去维护服务实例 不需要去检索服务
fetch-register: false
#设置与Enreka server交互的地址查询服务和注册服务都需要这个地址
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
<!--eureka-client-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
spring:
application:
name: cloud-payment-service
datasource:
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://localhost:3306/db2019?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true
username: root
password: 1234
mybatis:
mapper-locations: classpath:mapper/*.xml #配置文件
type-aliases-package: com.lyx.cloud.entities #所有entity别名所在包
eureka:
client:
register-with-eureka: true #自己注册到eureka 默认true
#是否从eureka抓取已有的注册信息 默认为true 单节点无所谓 集群必须为true 才能配合ribbon使用负载均衡
fetch-registry: true
service-url:
defaultZone: http://localhost:7001/eureka #注册中心地址
原文:https://www.cnblogs.com/lyx666/p/12748302.html