弹簧启动执行器端点-406不可接受

时间:2018-10-05 16:39:04

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

我的spring-boot执行器端点(例如/ health,/ env,/ info等)收到406不可接受的错误

我使用的是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")                   

1 个答案:

答案 0 :(得分:0)

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

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

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

有关更多详细信息,请参见here。您也可以在{strong> application.properties 中为管理端点customize the prefix,例如:

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

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