/actuator/info Endpoint가 스프링 부트 2.5.0에서 작동하지 않습니다.
앱에서 스프링 부트 버전을 2.4.4에서 2.5.0으로 업그레이드했는데 /actuator/info 끝점 노출이 중지되었습니다.여기 pom.xml과 application.yml이 있습니다.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ms</groupId>
<artifactId>spring-boot-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-test</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
application.yml
management:
endpoints:
jmx:
exposure:
include: "health,info"
스프링 부트 상위 버전 2.4.4에서는 애플리케이션이 정보 끝점을 노출할 수 있지만 2.5.0에서는 노출할 수 없습니다.
http를 통해 액추에이터 URL을 노출하는 올바른 속성은 다음과 같습니다.management.endpoints.web.exposure.exclude(web대신에jmx).
당신의 경우에는,info이전에 노출된 것은 제공한 속성이 있기 때문이 아니라 기본적으로 노출되었기 때문입니다.health하지만 2.5.0에서는 숨겨지므로 이제 수동으로 노출해야 합니다.
응용 프로그램 속성에 이 정보를 추가하여 /info 끝점을 표시합니다.
management.info.env.enabled = true
어리석은 실수였던 저의 경우, 저는 다음과 같은 의존성을 가지고 있었습니다.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
다음 대신:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
그래서 계속 Whiteabel Error Page 404 일부 /액추에이터 호출에서 찾을 수 없음
application.properties에서
#Actuator
management.endpoints.jmx.exposure.include=health,info,env,beans
management.endpoints.web.exposure.include=health,info,env,beans
사용 가능으로 설정해야 합니다.management.info.env.enabled true속성 파일 안에 원하는 세부 정보를 추가할 수 있습니다.아래와 같이사용 가능으로 설정해야 합니다.info웹.스캐너용.모든 구성은 아래와 같습니다.
.특성.
#enable /actuator/info
management.info.env.enabled=true
management.endpoints.web.exposure.include=info
#custom properties
info.app.name=order-service
info.app.version=1.0.0
info.app.description=you can insert any kind of data in the property file like this
info.author=mafei
.ymal
#enable /actuator/info
management:
info:
env:
enabled: true
endpoints:
web:
exposure:
include: info
#custom properties
info:
app:
name: order-service
version: 1.0.0
description: you can insert any kind of data in the property file like this
author: mafei
여기서 결과를 볼 수 있습니다.
다음은 액추에이터에 사용할 수 있는 세 가지 기본 끝점을 갖는 기본 그래들 빌드(kotlin dsl)입니다.
gradle.build.kts
build.gradle.kts
//Global variables
val junitVersion = "5.8.2"
val springVersion = "2.6.4"
val springWebVersion = "5.3.16"
plugins {
java
id("org.springframework.boot") version "2.6.4"
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
//spring boot
implementation("org.springframework:spring-web:$springWebVersion")
implementation("org.springframework.boot:spring-boot-starter-web:$springVersion")
implementation("org.springframework.boot:spring-boot-starter-actuator:$springVersion")
testImplementation("org.springframework.boot:spring-boot-starter-test:$springVersion")
}
tasks.getByName<Test>("test") {
useJUnitPlatform()
}
application.yml
#tomcat
server:
port: 7999
#actuator
management:
endpoints:
web:
exposure:
include: health,info,env,beans
gradlew bootRun:
액추에이터 끝점(예:
http://localhost:7999/actuator/health
엔드포인트 URL을 확인하려면 정보, 상태 및 콩과 같은 많은 것을 확인해야 합니다.액추에이터에 의한 .etc
첫 번째 포인트는 프로젝트에 액추에이터가 있는지 확인해야 하며, 없으면 다음과 같은 종속성을 추가해야 합니다.
<!--to enable actuator help to trace project--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>application.yml에 다음 스크립트를 추가하여 actuator 및 Prometheus by actuator를 활성화해야 합니다.
.
management:
security:
enabled: false
server:
port: 9000
endpoint:
metrics:
enabled: true
prometheus:
enabled: true
health:
show-details: always
show-components: always
probes:
enabled: true
shutdown:
enabled: true
info:
env:
enabled: true
enabled: true
endpoints:
web:
exposure:
include: prometheus, metrics, info, health, shutdown, beans
위 스크립트를 사용하면 액추에이터가 포트 9000에서 실행되고 다음 URL로 요청을 전송하여 액추에이터에 액세스할 수 있습니다.
http://localhost:9000/http
정보 경로에 액세스하기 위한 다음 URL
http://localhost:9000/http/info
참고: 엔드포인트와 엔드포인트가 혼동되었기 때문에 스크립트를 작성하는 위치를 확인해야 합니다.
- 액추에이터 구성을 설정할 끝점입니다.
- 액추에이터 URL 끝점을 설정하는 끝점입니다.
참고: 포트를 삭제할 수 있습니다. application.yml 프로그램 됩니다.
행운
언급URL : https://stackoverflow.com/questions/67893857/actuator-info-endpoint-not-working-with-spring-boot-2-5-0
'programing' 카테고리의 다른 글
| Firebase Auth 관련 예외를 검색하는 방법 (0) | 2023.07.05 |
|---|---|
| 오류: RPC 실패, 미결 읽기 데이터가 남아 있는 상태에서 컬 전송이 닫혔습니다. (0) | 2023.07.05 |
| plsql의 증분 함수 (0) | 2023.07.05 |
| C에서 강력한 유형 검사 적용(유형 정의에 대한 유형 엄격성) (0) | 2023.07.05 |
| 데이터 소스 'spring.datasource.url'을(를) 자동 구성하지 못했습니다. (0) | 2023.07.05 |

