使用eureka搭建服务集群步骤
服务端加入1.spring-cloud-starter-netflix-eureka-server(服务端依赖)
2.spring-boot-starter-security(安全认证依赖)
服务端yml配置
server:
port: ${port:8761} #配置集群取值当前端口
eureka:
client:
service-url:
defaultZone: ${defaultZone:http://v:123@localhost:8762/eureka} #8761向8762注册
fetch-registry: true
register-with-eureka: true
enabled: true
spring:
application:
name: eureka-server
security:
user:
name: v
password: 123
客户端加入1.spring-cloud-starter-netflix-eureka-client(客户端依赖)
客户端yml配置:
spring:
datasource:
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/school?useSSL=false&characterEncoding=UTF-8&useUnicode=true
jackson:
default-property-inclusion: _non_null #设置全局对象转jason数据为null时,不返回数据
_date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
application:
name: student
server:
port: 7777
pagehelper:
reasonable: true
_# mybatisPlus逻辑删除配置, 数据库需要添加deleted字段,实体类添加deleted属性,可以添加注解或者在yml配置文件全局配置
mybatis-plus:
global-config:
db-config:
logic-not-delete-value: 0 #0为可查询状态
logic-delete-field: 1 #1为逻辑删除状态
id-type: _auto
_configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 控制台日志打印
_mapper-locations: /mapper/*.xml
eureka:
client:
service-url:
defaultZone: http://v:123@localhost:8761/eureka