不显示 Spring Boot Actuator 的所有链接
Not show all links for Spring Boot Actuator
在我的 Spring 引导项目中:
build.gradle:
plugins {
id 'org.springframework.boot' version '2.2.2.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'war' // to use JSP
}
group = 'ru.otus.sd'
version = '0.0.1'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.h2database:h2'
implementation 'javax.servlet:jstl:1.2'
implementation 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
}
test {
useJUnitPlatform()
}
此处application.yml
managment:
endpoints:
web:
exposure:
include:
- beans
- health
- metrics
- env
server:
port: 8090
打开http://localhost:8090/actuator
这里的结果是:
{
"_links": {
"self": {
"href": "http://localhost:8090/actuator",
"templated": false
},
"health": {
"href": "http://localhost:8090/actuator/health",
"templated": false
},
"health-path": {
"href": "http://localhost:8090/actuator/health/{*path}",
"templated": true
},
"info": {
"href": "http://localhost:8090/actuator/info",
"templated": false
}
}
}
为什么不链接:/beans、/metrics?
你能试试下面的配置吗
management:
endpoints:
web:
exposure:
include: "*"
management:
endpoints:
web:
exposure:
include: info, health, metrics
metrics:
export:
atlas:
enabled: false
我在 application.yml
中添加了以下配置,并在执行器详细信息中获取指标和 beans
management:
server:
port: 9000
endpoint:
shutdown:
enabled: true
endpoints:
web:
exposure:
include:
- beans
- health
- metrics
- env
如果您使用的 application.yml
与您在问题中给出的相同,请将 management
的拼写更改为 managment
,因为拼写错误,我是也没有得到指标和 beans。
在我的 Spring 引导项目中:
build.gradle:
plugins {
id 'org.springframework.boot' version '2.2.2.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'war' // to use JSP
}
group = 'ru.otus.sd'
version = '0.0.1'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.h2database:h2'
implementation 'javax.servlet:jstl:1.2'
implementation 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
}
test {
useJUnitPlatform()
}
此处application.yml
managment:
endpoints:
web:
exposure:
include:
- beans
- health
- metrics
- env
server:
port: 8090
打开http://localhost:8090/actuator
这里的结果是:
{
"_links": {
"self": {
"href": "http://localhost:8090/actuator",
"templated": false
},
"health": {
"href": "http://localhost:8090/actuator/health",
"templated": false
},
"health-path": {
"href": "http://localhost:8090/actuator/health/{*path}",
"templated": true
},
"info": {
"href": "http://localhost:8090/actuator/info",
"templated": false
}
}
}
为什么不链接:/beans、/metrics?
你能试试下面的配置吗
management:
endpoints:
web:
exposure:
include: "*"
management:
endpoints:
web:
exposure:
include: info, health, metrics
metrics:
export:
atlas:
enabled: false
我在 application.yml
中添加了以下配置,并在执行器详细信息中获取指标和 beans
management:
server:
port: 9000
endpoint:
shutdown:
enabled: true
endpoints:
web:
exposure:
include:
- beans
- health
- metrics
- env
如果您使用的 application.yml
与您在问题中给出的相同,请将 management
的拼写更改为 managment
,因为拼写错误,我是也没有得到指标和 beans。