微服务 spring cloud 将服务注册到注册中心 (eureka)

eureka_client

环境版本

spring cloud  Greenwich.SR5
spring boot   2.1.6.RELEASE
jdk           11

pom 文件

<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>
        

项目 配置文件

server:
  port: 8030

spring:
  application:
  	# 注册到eureka server的服务名# 注册到eureka server的服务名
    name: order 
eureka:
  client:
    serviceUrl:
      # eureka server的地址
      defaultZone: http://eureka0:8010/eureka/, http://eureka1:8010/eureka/, http://eureka2:8010/eureka/ 

启动类添加注解

@EnableEurekaClient
@SpringBootApplication
public class OrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }

}

NOTE: 博客内容供参考学习,如有问题请指正,虚心接纳

发布了11 篇原创文章 · 获赞 0 · 访问量 395

猜你喜欢

转载自blog.csdn.net/qq_41692766/article/details/105537993
今日推荐