inflearn logo
강의

Course

Instructor

Microservice Application (MSA) Development with Spring Cloud

api-gateway 서버를 실행시키고 first-service와 second-service 를 실행시키면 api-gateway가 실행이 잘 안됩니다.

Resolved

1128

taekgyu06020582

26 asked

0

안녕하세요

Spring Cloud Gateway 프로젝트 생성 강의를 진행했는데요

제가 first-service와 second-service 그리고 api-gateway를 모두

Spring Boot 2.6.10 버전

java 11 버전

sdk도 11 로 생성했습니다.

 

우선 api-gateway의  application.yml 파일은 다음과 같습니다.

server:
port: 8000

eureka:
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://localhost:8761/eureka

spring:
application:
name: apigateway-service
cloud:
gateway:
routes:
- id: first-service
uri: http://localhost:8081/ # 여기로 요청할거다.
predicates: # 조건절이다.
- Path=/first-service/** # 사용자가 이걸호출하면 위에 uri로 간다. http://localhost:8081/first-service/** 으로 간다.
- id: second-service
uri: http://localhost:8082/ # 여기로 요청할거다.
predicates: # 조건절이다.
- Path=/second-service/** # 사용자가 이걸호출하면 위에 uri로 간다.

 

 

first-service의 application.yml 파일은 다음과 같고

server:
port: 8081

spring:
application:
name: my-first-service

eureka:
client:
fetch-registry: false
register-with-eureka: false

FirstServiceController는 다음과 같습니다.

@RestController
@RequestMapping("/first-service")
public class FirstServiceController {
@GetMapping("/welcome")
public String welcome() {
return "Welcome to the First service";
}
}

 

또한 second-service의 application.yml은 다음과 같고

server:
port: 8082

spring:
application:
name: my-second-service

eureka:
client:
fetch-registry: false
register-with-eureka: false

SecondServiceController는 다음과 같습니다.

@RestController
@RequestMapping("/second-service")
public class SecondServiceController {
@GetMapping("/welcome")
public String welcome() {
return "Welcome to the Second service";
}
}

 

브라우저에

http://127.0.0.1:8081/first-service/welcome 을 입력하면 Welcome to the First service가 잘뜨고

http://127.0.0.1:8082/second-service/welcome 을 입력하면 Welcome to the Second service 가 잘 뜹니다.

그런데

http://127.0.0.1:8000/first-sevice/welcome

http://127.0.0.1:8000/second-sevice/welcome

을 입력하면 역시나 동일하게 Welcome to the ~ 가 나와야하는데

Whitelabel Error Page

404 에러가 발생합니다... 원인이 무엇일까요?

참고로 api-gateway 서버를 먼저키고 first, second 켜보기도하고

first, second 서버 먼저 키고 api-gateway를 켜보기도했는데

상관없이 똑같은 에러가 발생합니다.

spring spring-boot springcloud gateway JPA architecture spring-cloud Kafka msa

Answer 1

0

taekgyu06020582

이런... service라고 쳐야하는데 sevice라고 쳤네요...

0

Dowon Lee

넵! 혹시 추가 질문 사항 있으시면 다시 글 남겨주세요. 바쁜 작업들이 거의 끝나서 바로 바로 확인할 수 있을거 같습니다. 감사합니다~

service-discovery 프로세스 가동 이유

0

43

1

rabbitmq에 configservice 연결에 대해 질문있습니다.

0

62

1

kafka 업데이트 강의 듣고 시포요

0

151

2

강의 교안

0

131

2

마이크로서비스간 통신 시, 인증 처리

0

149

2

api gateway 에서 인증 처리

0

93

1

섹션 19 질문드립니다

0

106

2

강의 자료 업데이트

0

132

2

부하분산 강의 섹션

0

85

1

강의자료는 어디에서?

0

117

2

강의 자료는 어디서 다운 받을 수 있나요?

0

162

2

전체 사용자 조회시 오류

0

78

1

혹시 pk 외 별도의 id 를 부여한 이유가 있을까요 ??

0

150

2

학습 방향

0

119

2

카프카 커넥터 사용 목적 문의

0

123

2

kafka 강의

0

140

2

서비스 디스커버리 종류

0

117

2

강의 자료에 대해서 궁금해요

0

151

2

GlobalFilter, LoggingFilter가 동작하지 않습니다.

0

114

2

Kafka Source Connect 버전 에러

0

127

2

소스커넥터는 사용안한 거 맞죠?

0

116

2

강의자료 업데이트 문의

0

109

2

강의에서 BCryptPasswordEncoder 에 역할(5-2)

0

77

1

강의 업데이트 계획이 궁금합니다.

0

134

2