org.springframework.boot
spring-boot-devtools
2.3.3.RELEASE
3、编写springcloud-eureka-7002的application.yaml配置文件和主启动类
application.yaml
server:
port: 7002
#Eureka配置
eureka:
instance:
#Eureka服务端的实例名称
hostname: localhost
client:
#表示是否向Eureka注册中心注册自己
register-with-eureka: false
#如果为false,则表示自己为注册中心
fetch-registry: false
#监控页面
service-url:
#eureka.instance.hostname对应上面的localhost, server.port 7001
#http://localhost:7001/eureka/
设置与Eureka Server交互的地址查询服务和注册服务都需要依赖这个defaultZone地址
#eureka server服务注册中心地址 暴露服务地址
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/
主启动类
package com.study.srpingcloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer //开启Eureka服务,可以接收别人注册进来
public class EurekaServer_7002 {
public static void main(String[] args) {
SpringApplication.run(EurekaServer_7002.class,args);
}
}
启动测试
4、编写springcloud-eureka-7003的application.yaml配置文件和主启动类
application.yaml
server:
port: 7003
#Eureka配置
eureka:
instance:
#Eureka服务端的实例名称
hostname: localhost
client:
#表示是否向Eureka注册中心注册自己
register-with-eureka: false
#如果为false,则表示自己为注册中心
fetch-registry: false
#监控页面
service-url:
#eureka.instance.hostname对应上面的localhost, server.port 7001
#http://localhost:7001/eureka/
设置与Eureka Server交互的地址查询服务和注册服务都需要依赖这个defaultZone地址
#eureka server服务注册中心地址 暴露服务地址
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/
主启动类
package com.study.springcloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer //开启Eureka服务,可以接收别人注册进来
public class EurekaServer_7003 {
public static void main(String[] args) {
SpringApplication.run(EurekaServer_7003.class,args);
}
}
启动测试
===================================================================
1、进入电脑C盘C:\Windows\System32\drivers\etc目录打开hosts文件,在hosts文件最后加上,要访问的本机名称,默认是localhost
127.0.0.1 eureka7001.com
127.0.0.1 eureka7002.com
127.0.0.1 eureka7003.com
2、修改springcloud-eureka-7001、springcloud-eureka-7002和springcloud-eureka-7003的application.yml配置文件
3、在集群中使springcloud-eureka-7001关联springcloud-eureka-7002、springcloud-eureka-7003
service-url:
#eureka.instance.hostname对应上面的localhost, server.port 7001
#http://localhost:7001/eureka/
设置与Eureka Server交互的地址查询服务和注册服务都需要依赖这个defaultZone地址
单机: 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/
集群(关联):7001关联7002、7003
#eureka server服务注册中心地址 暴露服务地址
defaultZone: http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/
4、在集群中使springcloud-eureka-7002关联springcloud-eureka-7001、springcloud-eureka-7003
service-url:
#eureka.instance.hostname对应上面的localhost, server.port 7001
#http://localhost:7001/eureka/
设置与Eureka Server交互的地址查询服务和注册服务都需要依赖这个defaultZone地址
单机: 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/
集群(关联):7002关联7001、7003
#eureka server服务注册中心地址 暴露服务地址
defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7003.com:7003/eureka/
5、在集群中使springcloud-eureka-7003关联springcloud-eureka-7001、springcloud-eureka-7002
service-url:
#eureka.instance.hostname对应上面的localhost, server.port 7001
#http://localhost:7001/eureka/
设置与Eureka Server交互的地址查询服务和注册服务都需要依赖这个defaultZone地址
单机: 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/
集群(关联):7003关联7001、7002
defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/
6、修改springcloud-provider-dept-8001下的yml配置文件,配置服务注册中心地址
#Eureka配置,服务注册到哪里
eureka:
client:
service-url:
#eureka server服务注册中心地址 暴露服务地址
defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/
instance:
instance-id: springcloud-provider-dept8001 #修改Eureka默认描述信息
7、Eureka集群搭建完成,启动测试
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)
最后的话
无论是哪家公司,都很重视Spring框架技术,重视基础,所以千万别小看任何知识。面试是一个双向选择的过程,不要抱着畏惧的心态去面试,不利于自己的发挥。
同时看中的应该不止薪资,还要看你是不是真的喜欢这家公司,好了希望这篇文章对大家有帮助!
部分截图:
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
https://img-blog.csdnimg.cn/img_convert/25557ac099af9b3fdc5794a0b1f31c7c.jpeg" alt=“img” style=“zoom: 33%;” />
最后的话
无论是哪家公司,都很重视Spring框架技术,重视基础,所以千万别小看任何知识。面试是一个双向选择的过程,不要抱着畏惧的心态去面试,不利于自己的发挥。
同时看中的应该不止薪资,还要看你是不是真的喜欢这家公司,好了希望这篇文章对大家有帮助!
部分截图:
[外链图片转存中…(img-1xPannnc-1713581527936)]
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!