728x90
반응형
@EnableEurekaClient를 사용해도 되고,
@EnableDiscoveryClient
를 사용해도 됨
application.yml 에 service-url 은 Eureka Server 주소를 등록
service-url:
defaultZone: http://localhost:8761/eureka
실행하고 다시 Application 을 보면, MY-FIRST-SERVICE 보임
동일 소스파일의 application.yml 의 포트를 바꾸면, 서비스를 하나 더 실행할 수 있다.
Availlability Zones 의 숫자가 2로 변경됨
■ 다른 방식으로 기동. 터미널을 열고 아래와 같이 기동을 하니 에러남.
first-service>mvnw spring-boot:run -Dspring-boot.run.jvmArguments='-Dserver.port=9003'
■ jar 파일을 만들어 띄우는 방법도 있다.
mvnw clean compile package
java -jar ./target/first-service-0.0.1-SNAPSHOT.jar --server.port=9004
Eureka Client 의 Server.port 를 0 으로 주면, 랜덤하게 포트가 생성된다.(application.yml)
server:
port: 0
단 이때는 하나만 뜨므로...아래 문구를 넣으면 여러게 뜬다.
instance:
instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}}
728x90
반응형
'IT > Spring Boot' 카테고리의 다른 글
IntelliJ Community 버전에서 Spring Boot 프로젝트 만들기 (0) | 2022.09.01 |
---|---|
Spring Cloud API Gateway (0) | 2022.08.30 |
서비스 Discovery (Spring Cloud + Eureka) (0) | 2022.08.30 |
[Mybatis] 초기 설정 및 xml 파일 설정 (0) | 2022.08.11 |
Visual Studio Code에서 Spring 개발 환경 꾸미기 (0) | 2022.05.02 |
댓글