Springboot-Eureka搭建

  1. 引入 eureka-server 依赖
<!--SpringCloud eureka-server -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
  1. 配置application.yml
###服务端口号
server:
  port: 8100
###eureka 基本信息配置
eureka:
  instance:
    ###注册到eurekaip地址
    hostname: 127.0.0.1
  client:
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
    ###因为自己是为注册中心,不需要自己注册自己
    register-with-eureka: false
    ###因为自己是为注册中心,不需要检索服务
    fetch-registry: false

  1. 创建eureka启动类
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class AppEureka {
    public static void main(String[] args) {
        SpringApplication.run(AppEureka.class,args);
    }
}
  1. 启动启动类
    http://localhost:8100/
    在这里插入图片描述
    到此Eureka搭建完毕
发布了12 篇原创文章 · 获赞 0 · 访问量 363

猜你喜欢

转载自blog.csdn.net/dawn_li/article/details/103923161
今日推荐