spring-boot 프로젝트 생성
intellij new 프로젝트
Eureka-Server
server:
port: 8761
spring:
application:
name: service-discovery
eureka:
client:
register-with-eureka: false
fetch-registry: false
Eureka-Client
spring:
application:
name: user-service
server:
port: 60000
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: <http://localhost:8761/eureka/>
Scaling - Random 포트 사용으로 같은 서비스 추가 실행
port = 0 설정.
spring:
application:
name: user-service
server:
port: 0 // 랜덤 포트 설
eureka:
instance:
instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value} // 인스턴스 id 부여 랜덤 값으}
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: <http://localhost:8761/eureka/>
CLI 실행
mvn spring-boot:run "-Dspring-boot.run.jvmArguments=-Dserver.port=60001"
mvn 빌드 후 jar로 실행
java -jar ./user-service-0.0.1-SNAPSHOT.jar // 기본 설정된 포트로 실행됨
//실행시 포트 변경
java -jar "-Dserver.port=60003" ./user-service-0.0.1-SNAPSHOT.jar