在Idea中新建Spring Initializr项目(即SpringBoot项目),然后选择添加Spring Cloud Discory依赖——eureka_server依赖,生成的项目即为注册中心服务eureka_server。在EurekaServerApplication类中添加@EnableEurekaServer,修改配置文件为yml文件,在配置文件中添加
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
#声明自己是个服务端
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://
e
u
r
e
k
a
.
i
n
s
t
a
n
c
e
.
h
o
s
t
n
a
m
e
:
{eureka.instance.hostname}:
eureka.instance.hostname:{server.port}/eureka/
启动项目即可
创建注册中心服务eureka_server
最新推荐文章于 2023-10-12 10:56:32 发布