강의

멘토링

로드맵

인프런 커뮤니티 질문&답변

리자몽님의 프로필 이미지
리자몽

작성한 질문수

Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)

actuator 방법이 안됩니다.

작성

·

813

0

Configuration 서버의 정보가 변경이 됐을 때 정보를 다시 가지고 오는 방법들이 있는데 두번째 방법인

actuator를 이용하는데 refresh, health, beans 전부 안됩니다.

 
health_check로 값을 확인하면 아래처럼 잘뜹니다.
It's Working in User Service, port(local.server.port)=56550, port(server.port)=0, token secret=user_token, token expiration time=86400000
 
 
참고로 user-service에
bootstrap.yml 파일은
spring:
cloud:
config:
uri: http://127.0.0.1:8888
name: ecommerce # ecommerce.yml 파일을 가져온다.
 
git-local-repo에 있는 ecommerce.yml은 다음과 같습니다.
token:
expiration_time: 86400000
secret: user_token

gateway:
ip: 192.168.45.163
 
그리고
config-service에 있는 application.yml 파일은
server:
port: 8888

spring:
application:
name: config-service
cloud:
config:
server:
git:
uri: file://C:\Users\test\IdeaProjects\Inflearn\msa\git-local-repo

다음과 같습니다.
그런데 actuator 방법은 /health와 /beans 모두 Whitelabel Error Page가 뜨고
 
/refresh로 post 요청하면
{
    "timestamp""2022-08-20T11:28:26.532+00:00",
    "status"404,
    "error""Not Found",
    "message""No message available",
    "path""/actuator/refresh"
}
위와 같은 에러가 발생합니다..
참고로 user-service의 application.yml에
management:
endpoints:
web:
exposure:
include: refresh, health, beans
을 추가했습니다.
그런데 강의처럼 자동완성은 전혀 뜨지 않았습니다.
endpoints 부터 자동완성이 없었습니다. 대체 왜이런걸까요?
 
 
그리고 
user-service에서 실행시키면
도대체 왜 config-service 프로젝트에 있는 application.yml 파일에 등록된
`uri: file://C:\Users\test\IdeaProjects\Inflearn\msa\git-local-repo` ( 제 ecommerce.yml 주소)
이 주소를 읽는건지 모르겠습니다.
user-service의 bootstrap.yml에는 ecommerce(.yml) 밖에 없는데…
저 config-service에 있는 application.yml을 참조 하라는 표시를 대체 어디에 한건가요??
 

답변 1

0

Dowon Lee님의 프로필 이미지
Dowon Lee
지식공유자

안녕하세요, 이도원입니다. 

actuator 사용을 위해 pom.xml 파일에 아래 Dependency가 추가 되어 있는지 확인해 보시기 바랍니다.

 

두번째, management.endpoints.web.exposure.include 와 같은 설정은 코드 자동 완성을 해 주는 플러그인이 설치되어 있어야 가능합니다. application.yml 파일을 intellij 에서 편집 하시면 자동 완성 기능을 사용할실 수 있을 것 같습니다. 

세번째로, user-service의 bootstrap.yml 파일에 설정 된 정보를 통해 config-service로부터 설정 정보를 가져오도록 구현하셨다면, user-service가 기동 될 때, 콘솔로그에서 제일 상단에 보이는 설정 파일의 정보를 확인해 볼 수 있습니다. 어디에서 어떤 파일을 읽었는지 표시될 겁니다. ecommerce.yml 파일과 같이 애플리케이션 이름의 YAML 파일일 존재할 때도 application.yml 파일과 ecommerce.yml 파일을 내용을 같이 가져오고, ecommerce.yml 파일의 내용을 우선적으로 사용합니다. ecommerce..yml 파일에 특정 값이 없을 경우에는 application.yml 파일의 내용을 가져오고, application.yml 파일에도 없을 경우에는 해당 값이 없다고 오류가 발행합니다. 

말씀하신, file://C:\Users\test\IdeaProjects\Inflearn\msa\git-local-repo 폴더를 삭제하신 다음에 다시 실행해 보시기 바랍니다. 혹시 그래도 같은 현상이면 해당 config-service와 user-service의 YAML 파일을 보내주시면, 제쪽에서 확인해 보도록 하겠습니다. 

edowon0623@gmail.com

감사합니다. 

리자몽님의 프로필 이미지
리자몽
질문자

답변 감사합니다 actuator beans, health ,refresh 요청 문제는

다행히도 이후 강의를 듣다가 dependency를 추가했는데

해결이 됐습니다.

리자몽님의 프로필 이미지
리자몽

작성한 질문수

질문하기