工具:IntelliJ IDEA 2017.1.2 x64,maven3.3.9
打开 IDE file===>new===>project
next
next
选择相应的依赖
next
finish
查看下上述我们选的两个依赖在 pom.xml 中
通过@EnableEurekaServer注解启动一个服务注册中心
在默认情况下该服务注册中心会将自己作为客户端来尝试注册它自己,所以我们需要禁用它的客户端行为,只需在 application.properties 中做如下配置:
# 指定服务的端口号
server.port=1111
# 注册中心实例名称
eureka.instance.hostname=localhost
# 表示不向注册中心注册自己
eureka.client.register-with-eureka=false
# 由于注册中心的职责就是维护服务实例并不需要去检索实例所以设置为false
eureka.client.fetch-registry=false
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/
启动项目
通过http://localhost:1111访问服务注册中心页面
基于 eureka server 的服务注册中心搭建完成.
来源: http://www.bubuko.com/infodetail-2467826.html