spring cloud創建服務註冊中心

創建一個 ==spring boot== 工程 ,在pom.xml中引入 ==eureka-server== 依賴

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

在==springboot應用==中添加==@EnableEurekaServer==註解,啓動一個服務註冊中心

@EnableEurekaServer
@SpringBootApplication
public class ServerApplication {

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

修改application.yml配置

spring:
  application:
    name: server
server:
  port: 10000
eureka:
  instance:
    hostname: localhost
  client:
    register-with-eureka: false
    fetch-registry: false
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章