티스토리 뷰

반응형
  • Spring Boot 2.5.2
  • IntelliJ 2020.3.3

1. Eureka Server

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
eureka:
  instance:
    appname: injuk-server
  client:
    fetch-registry: false
    register-with-eureka: true
@SpringBootApplication
@EnableEurekaServer
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

2. Eureka Client

dependencies {
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
server:
  port: 8080
eureka:
  instance:
    appname: injuk-client
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://localhost:8761/eureka/
@SpringBootApplication
@EnableEurekaClient
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

 

3. Eureka dashboard 접속

  • http://localhost:8761
    • http://localhost:8761/eureka/apps도 확인해보자.

 

배운 것

  • 포트 겹치면 당연히 안됨
  • EnableEurekaClient와 EnableDiscoveryClient는 다름 (참고)
  • dependencies에 eureka client용과 server용을 같이 넣지 말자.
    • 에러가 발생하며 실행되지 않는다. 실습해본다고 spring initializr에서 다 체크해서 문제가 발생하였음... 
      • error getting CloudEurekaClient
      • Error creating bean with name 'scopedTarget.eurekaClient' defined in class path resource, 등 
    • > 이유 찾아보기

'Dev. > java' 카테고리의 다른 글

[Java] 현재 사용 중인 GC 보기  (0) 2021.07.19
[Spring Boot] property를 읽어들이는 순서  (0) 2021.07.17
[Java] HttpURLConnection  (0) 2021.05.21
[Java] Primitive type, Reference type  (0) 2021.02.04
[Java] 디자인 패턴 - Singleton  (0) 2020.10.22
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함