依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<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-actuator</artifactId>
</dependency>
</dependencies>
启动类增加注解
@SpringBootApplication
@EnableEurekaClient
public class SpringWebDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringWebDemoApplication.class, args);
}
}
配置文件
eureka.instance.appname=web-demo
eureka.instance.app-group-name=web
eureka.instance.prefer-ip-address=true
eureka.instance.ip-address=127.0.0.1
eureka.instance.instance-id= ${spring.application.name}:${server.port}
#eureka.instance.home-page-url-path=/
#eureka.instance.health-check-url-path=/health
#eureka.instance.status-page-url-path=/status
eureka.instance.lease-expiration-duration-in-seconds=30
eureka.instance.lease-renewal-interval-in-seconds=10
eureka.client.serviceUrl.defaultZone=http://localhost:19002/eureka/,http://localhost:19001/eureka/
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/194462.html