SpringCloud之註冊中心微服務搭建

1、導入依賴:pom.xml

 <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>
</dependencies>

2、配置文件:application.yml

server:
  port: 8001
spring:
  application:
    name: euraka
eureka:
  instance:
    hostname: 127.0.0.1
  client:
    fetch-registry: false #是否從eureka中獲取信息
    register-with-eureka: false #是否將自己註冊到eureka中
    service-url:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

3、啓動類:EurekaApplication

@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaApplication.class, args);
    }
}

4、瀏覽器訪問:http://127.0.0.1:8001

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章