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://www.lhsxpumps.com/_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>
本文地址:https://blog.csdn.net/weixin_42654295/article/details/107599449
如对本文有疑问, 点击进行留言回复!!
HashMap、Hashtable、ConcurrentHashMap三者间的异同
解决RecycleView 中Item包含Edittext时,滑动view复用导致数据错乱的问题
多线程、同步工作原理、死锁案例、Lock接口、线程的生命周期的讲解及实现
网友评论