【问题标题】:Spring-boot Actuator endpoints - 406 Not AcceptableSpring-boot 执行器端点 - 406 不可接受
【发布时间】:2019-03-11 05:15:26
【问题描述】:

我的 spring-boot 执行器端点(如 /health、/env、/info 等)收到 406 Not Acceptable 错误

我使用的是 spring-boot 1.5.8 版

访问端点,例如 http://localhost:6061/health http://localhost:6061/env

这是我的 gradle 构建文件的一部分

buildscript {            
ext {            
    springBootVersion = '1.5.8.RELEASE'            
}                
dependencies {                        
    classpath(group: 'org.springframework.boot', name: 'spring-boot- 
gradle-plugin', version:'1.5.8.RELEASE')            
}            
}                  
repositories {            
mavenLocal()            
maven {            
    url "${artifactory_url}" + "libs-release"            
    credentials {            
        username = "${artifactory_user}"            
        password = "${artifactory_password}"            
    }            
}            
maven {            
    url "${artifactory_url}" + "libs-snapshot"            
    credentials {            
        username = "${artifactory_user}"            
        password = "${artifactory_password}"            
    }            
}                   
}       
apply plugin: 'com.jfrog.artifactory'            
 apply plugin: 'java'                                 
apply plugin: 'org.springframework.boot'            
apply plugin: 'project-report'     
dependencies {               
compile("org.apache.commons:commons-csv:1.4")            
runtime 'com.google.guava:guava:19.0'                        
 compile fileTree(dir: 'src/libs/', include: '*.jar')                      
compile("org.springframework.cloud:spring-cloud-stream:1.2.2.RELEASE")            
compile('org.springframework.cloud:spring-cloud-starter-hystrix- 
dashboard:1.3.1.RELEASE')            
compile('org.springframework.cloud:spring-cloud-starter- 
hystrix:1.3.1.RELEASE')            
compile('org.springframework.cloud:spring-cloud-starter- 
eureka:1.3.1.RELEASE')            
compile('org.springframework.cloud:spring-cloud-starter- 
turbine:1.3.1.RELEASE')                  
compile("org.springframework.boot:spring-boot-starter-actuator")                   

【问题讨论】:

  • 我想问题是如何成功访问端点?您可以使用访问端点的方式更新票证吗?
  • @Boris 添加了上面的评论,访问这个端点localhost:6061/health
  • 您也可以添加应用程序属性文件吗?您有任何与执行器相关的设置吗?
  • @Boris 我的 application.properties 中没有任何与执行器相关的设置。

标签: spring-boot spring-boot-actuator http-status-code-406


【解决方案1】:

在 Spring Boot 中,执行器端点通常通过 HTTP 公开,并映射到前缀为 /actuator 的 URL。例如,默认情况下,health 端点映射到 /actuator/health

如果您的应用程序在端口 6061 上本地运行,则正确的 URL 将是:

http://localhost:6061/actuator/health
http://localhost:6061/actuator/env

请参阅here 了解更多详情。您也可以在 application.properties 中为管理端点customize the prefix,例如:

management.endpoints.web.base-path=/manage

这会将端点从 /actuator/{id} 更改为 /manage/{id}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-26
    • 2018-12-06
    • 1970-01-01
    • 2013-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多