在我的Spring Boot项目中:
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
中添加了以下配置,并在执行器详细信息中获取了度量和bean
management:
server:
port: 9000
endpoint:
shutdown:
enabled: true
endpoints:
web:
exposure:
include:
- beans
- health
- metrics
- env
如果您使用与所给问题相同的application.yml
,请在将其写为management
时更改managment
的拼写,因为使用了错误的拼写,我也没有得到指标和Bean。] >