본문 바로가기
Infra System

Eureka Server(standalone) - Outer Architecture

by kellis 2020. 10. 14.

pom.xml

air-starter를 상속받고, netflix가 제공하는 eureka-server를 dependency에 추가합니다. 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>kr.sys4u.lab</groupId>
        <artifactId>air-starter</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>kr.sys4u.lab</groupId>
    <artifactId>air-eureka-server-starter</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>air-eureka-server-starter</name>
    <description>Demo project for Spring Boot</description>
 
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>
    </dependencies>
 
</project>

application.yml

application.yml에 eureka-server에 대한 세팅을 해주어야 합니다. 

server:
  port: 7979
spring:
  application:
    name: air-eureka-server-starter
eureka:
  client:
    service-url:
      defaultZone: http://localhost:7979/eureka
    registerWithEureka: false
    fetchRegistry: false
  • 10라인: eureka-server를 standalone으로 구성한 상태라 1대의 eureka-server 정보를 세팅했습니다. cluster 구성을 위해서는 추가적인 설정이 필요하지만, 지금은 생략하도록 하겠습니다.

springboot main

[AirEurekaServerApplication.kt]

@EnableEurekaServer
@SpringBootApplication
class AirEurekaServerApplication
 
fun main(args: Array<String>) {
    runApplication<AirEurekaServerApplication>(*args)
}
  • 1라인: Springboot Main 클래스에 @EnableEurekaServer 을 추가해주어야 해당 애플리케이션이 Eureka-server로 동작합니다.

댓글