Eureka setting
Eureka ๋ ์๊ฐ ๋ฑ๋ก, ๋์ ๋ฐ๊ฒฌ ๋ฐ ๋ถํ ๋ถ์ฐ์ ๋ด๋นํ๋ฉฐ ์์ ์๋น์ค ๋์ค์ปค๋ฒ๋ฆฌ ํจํด์ ๊ตฌํํ ์ ์๋๋ก ๋์์ค๋ค.
๋ชจ๋ ๋ง์ดํฌ๋ก์๋น์ค๊ฐ ์์ ์ ๊ฐ์ฉ์ฑ์ ๋ฑ๋กํ๋ ๋ ์ง์คํธ๋ฆฌ
๋ฑ๋ก๋ ๋ง์ดํฌ๋ก์๋น์ค๋ฅผ ํธ์ถํด์ ์ฌ์ฉํ ๋ Eureka Client ๋ฅผ ์ด์ฉํด์ ํ์ํ ์๋น์ค๋ฅผ ๋ฐ๊ฒฌ
๋ฑ๋ก๋๋ ์ ๋ณด๋ ์๋น์ค ID์ URL ์ด ํฌํจ๋๋๋ฐ, ๋ง์ดํฌ๋ก์๋น์ค๋ Eureka Client ๋ฅผ ์ด์ฉํด์ ์ด ์ ๋ณด๋ฅผ Eureka Server ์ ๋ฑ๋ก
Eureka Server ๋ Eureka Server ์ธ ๋์์ ์๋ก์ ์ํ๋ฅผ ๋๊ธฐํํ๊ธฐ ์๋ก๋ฅผ ๋ฐ๋ผ๋ณด๋ Eureka Client ์ด๊ธฐ๋ ํ๋ค ์ด ์ ์ Eureka Server ์ ๊ณ ๊ฐ์ฉ์ฑ์ ์ํด ์ฌ๋ฌ ๋์ Eureka Server ์ด์ ์ ์ ์ฉ
START EUREKA
SERVER SETTING
์์กด์ฑ ์ถ๊ฐ springCloudVersion ๋ฒ์ ์ฐธ๊ณ
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.4'
}
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "2023.0.0")
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
์ค์ ํ์ฑํ
@SpringBootApplication
@EnableEurekaServer
class EurekaApplication
fun main(args: Array<String>) {
runApplication<EurekaApplication>(*args)
}
์ค์ ํ์ผ
spring:
application:
name: eureka-server
profiles:
active: dev
server:
port: 8761
eureka:
server:
enable-self-preservation: true
instance:
hostname: api-discovery.com
secure-port: ${server.port}
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://api-discovery.com:8761/eureka
disable-delta: true
์ ์ง์ ํด ์ค๋ค ์คํํ๋ฉด

CLIENT SETTING
์์กด์ฑ ์ถ๊ฐ
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
์ค์ ํ์ฑํ
@SpringBootApplication
@EnableEurekaClient
public class EurekaclientApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaclientApplication.class, args);
}
}
์ค์ ํ์ผ
server:
port: 8080
spring:
application:
name: user-Service
profiles:
active: dev
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8761/eureka
๋๋ก๋ซ๋ค๋ ๋ก๊ทธ๋ฅผ ํ์ธํ ์ ์๋ค.
2023-06-26 17:50:02.551 INFO 3560 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8080
2023-06-26 17:50:02.626 INFO 3560 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_USER-SERVICE/host.docker.internal:user-Service:8080 - registration status: 204
2023-06-26 17:50:02.788 INFO 3560 --- [ main] git.io.apiuser.ApiUserApplicationKt : Started ApiUserApplicationKt in 4.559 seconds (JVM running for 5.463)
Last updated