SpringCloud:1章 Eureka服务注册与发现
程序员文章站
2022-05-09 10:28:17
新建Eureka模块配置yml文件```javaserver: port: 2001eureka: instance: hostname: localhost #eurake实例名 client: service-url: defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka register-with-eureka: false #表示不想注册中心注册自已....
- 新建Eureka模块
- 配置yml文件
server:
port: 2001
eureka:
instance:
hostname: localhost #eurake实例名
client:
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka
register-with-eureka: false #表示不想注册中心注册自已
fetch-registy: false #表示不需要检索服务
3.启动类加上@EnableEurekaServer注解
@EnableEurekaServer
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
4.访问http://localhost:2001/ 出现如下画面则成功
5. 创建注册者模块
6. 配置yml文件
server:
port: 2002
spring:
application:
name: clinet_1 #注册名字
eureka:
client:
service-url:
defaultZone: http://localhost:2001/eureka
7.启动类加入注解@EnableEurekaClient
@EnableEurekaClient
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
- 检查依赖是否有这两个
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
- 访问http://localhost:2001 成功则出现
本文地址:https://blog.csdn.net/weixin_42654295/article/details/107599449
上一篇: js中随机生成UserAgent 的方法
推荐阅读
-
springcloud干货之服务注册与发现(Eureka)
-
SpringCloud之服务注册与发现Spring Cloud Eureka实例代码
-
springcloud干货之服务注册与发现(Eureka)
-
SpringCloud之服务注册与发现Spring Cloud Eureka实例代码
-
springcloud使用之服务的注册发现与消费
-
基于 Consul 实现 MagicOnion(GRpc) 服务注册与发现
-
Eureka(服务注册与发现)简单入门
-
SpringCloud-微服务的注册与发现Eureka
-
SpringCloud之Eureka:服务发布与调用例子
-
SpringCloud微服务实战:一、Eureka注册中心服务端