首页 文章

spring 启动 Actuator endpoints - 406不可接受

提问于
浏览
1

我的 spring 启动 Actuator endpoints 如/ health,/ env,/ info等我得到406 Not Acceptable错误

我使用的是spring-boot 1.5.8版

访问 endpoints ,如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

    在Spring Boot中, Actuator endpoints 通常通过HTTP公开,并映射到前缀为 /actuator 的URL . 例如,默认情况下, health endpoints 映射到 /actuator/health .

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

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

    有关详细信息,请参阅here . 您还可以customize the prefix用于 application.properties 中的管理 endpoints ,例如:

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

    这会将 endpoints 从 /actuator/{id} 更改为 /manage/{id} .

相关问题