-
在Spring Cloud项目的pom文件中添加eureka-server的starter依赖坐标
1.XML<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.app</groupId> <artifactId>study-spring-cloud</artifactId> <version>1.0.0</version> </parent> <artifactId>eureka-server</artifactId> <dependencies> <!-- eureka-server依赖 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> </dependencies> <build> <finalName>app</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
-
编写spring boot启动类,并在启动类上添加注解@EnableEurekaServer
1.javapackage com.app.eureka; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; /** * 添加Eureka的服务启动类 * * @author Administrator */ @SpringBootApplication @EnableEurekaServer public class EurekaApplication { public static void main(String[] args) { SpringApplication.run(EurekaApplication.class, args); } }
-
添加并编写application.yml文件
1.objectivecserver: port: 9000 spring: application: name: eureka-server eureka: client: service-url: # 服务端暴露的地址 defaultZone: http://127.0.0.1:9000/eureka
-
启动eureka-server服务,启动成功后访问地址Eureka
http://127.0.0.1:9000/
- 看到以下结果则表示已经启动成功
- 看到以下结果则表示已经启动成功
-
同时可以看出eureka-server即作为服务的注册中心,同时也将自己的服务注册到eureka-server上面,这是为了进行集群部署的时候需要用到的
如何搭建eureka-server
upton-nan2023-12-09 18:06
相关推荐
麦兜*43 分钟前
Spring Boot 企业级动态权限全栈深度解决方案,设计思路,代码分析ruan1145142 小时前
MySQL4种隔离级别Hellyc6 小时前
基于模板设计模式开发优惠券推送功能以及对过期优惠卷进行定时清理lifallen6 小时前
Paimon LSM Tree Compaction 策略hdsoft_huge6 小时前
SpringBoot 与 JPA 整合全解析:架构优势、应用场景、集成指南与最佳实践百锦再7 小时前
详细解析 .NET 依赖注入的三种生命周期模式程序员的世界你不懂7 小时前
基于Java+Maven+Testng+Selenium+Log4j+Allure+Jenkins搭建一个WebUI自动化框架(2)对框架加入业务逻辑层有没有没有重复的名字8 小时前
线程安全的单例模式与读者写者问题程序员的世界你不懂9 小时前
基于Java+Maven+Testng+Selenium+Log4j+Allure+Jenkins搭建一个WebUI自动化框架(4)集成Allure报表isNotNullX10 小时前
数据中台架构解析:湖仓一体的实战设计