SpringClould使用-Eureka

it2023-10-29  74

SpringClould使用-Eureka

项目截图pom引入application.yml启动类上添加@EnableEurekaServer启动测试:

项目截图

pom引入

<?xml version="1.0" encoding="UTF-8"?> <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/xsd/maven-4.0.0.xsd"> <parent> <artifactId>Spring-Cloud-ForLearning</artifactId> <groupId>com.wx</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>eureka-server</artifactId> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> </dependencies> </project>

application.yml

server: port: 8080 eureka: instance: # 指定该Eureka实例的主机名 hostname: localhost # 配置关闭自我保护,并按需配置Eureka Server清理无效节点的时间间隔 server: enable-self-preservation: false eviction-interval-timer-in-ms: 4000 # 通过eureka.client.registerWithEureka:false和fetchRegistry:false,来表明自己是一个eureka server client: register-with-eureka: false fetch-registry: false serviceUrl: defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

启动类上添加@EnableEurekaServer

启动测试:

http://localhost:8080/

最新回复(0)