dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
server:
port: 8761
# address: 127.0.0.1
spring:
application:
name: registry-server
eureka:
instance:
hostname: localhost
prefer-ip-address: true
# ip-address: ${server.address}
instance-id: ${spring.application.name}:${spring.application.intance_id:${server.port}}
client:
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
register-whit-eureka: false
fetch-registry: false
유레카서버로서 동작하게 어노테이션 추가
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
// implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.cloud:spring-cloud-starter-gateway'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
}
유레카 서버 디펜던시
actuator 추가하여 endpoint 확인 및 healthcheck
server:
port: 8080
# address: 127.0.0.1
eureka:
instance:
hostname: localhost
prefer-ip-address: true
# ip-address: ${server.address}
instance-id: ${spring.application.name}:${spring.application.intance_id:${server.port}}
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8761/eureka
management:
endpoint:
gateway:
enabled: true
endpoints:
web:
exposure:
include: "*"
spring:
main:
web-application-type: reactive
application:
name: apigateway-service
cloud:
gateway:
discovery:
locator:
# 유레카 서비스로 받은 서비스 등록정보로 경로를 동적 생성
enabled: true
lower-case-service-id: true
metrics:
enabled: true
# httpclient:
# proxy:
# host: localhost
routes:
- id: sample-api
uri: lb://SAMPLE-API
predicates:
- Path=/sample-api/**
유레카 클라이언트로서 동작하게 어노테이션 추가
테스트용 spring boot api server
gateway와 마찬가지로 클라이언트로 등록해준다.