Eureka配置中心
添加依赖<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-server</artifactId></dependency>启动类注解@EnableEurekaServer
·
添加依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
启动类注解
@EnableEurekaServer 触发eureka服务器的自动配置
配置yml
spring:
application:
name: eureka-server
server:
port: 2001
eureka:
server:
# 禁用自我保护模式
enable-self-preservation: false
instance:
hostname: eureka1
client:
register-with-eureka: false #不向自身注册
fetch-registry: false #不从自身拉取注册信息
配置多个eureka
eureka1:application-eureka1.yml
eureka:
instance:
hostname: eureka1
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://eureka2:2002/eureka
eureka2:application-eureka2.yml
eureka:
instance:
hostname: eureka2
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://eureka1:2001/eureka
更改启动参数
设置两个:
--spring.profiles.active=eureka1 --server.port=2001
--spring.profiles.active=eureka2 --server.port=2002
更多推荐
已为社区贡献1条内容
所有评论(0)