【发布时间】:2019-02-03 12:32:42
【问题描述】:
我有一个 spring boot rest api 项目 - 我无法让 spring boot actuator /health 端点工作。它根本没有出现,当我尝试访问 localhost:8080/health 时,我得到一个“Whitelabel 错误页面”。我已经尝试向我的 application.properties 添加各种属性,但似乎都不起作用 - 无论如何,我不需要对执行器端点进行任何自定义映射或身份验证。下面是我的 build.gradle - 有什么建议吗?我想我错过了什么。
谢谢。
buildscript {
repositories {
mavenLocal()
maven { url = 'https://artifactory.company.com/libs-release' }
maven { url = 'https://artifactory.company.com/libs-remote' }
maven { url = 'https://artifactory.company.com/libs-snapshot' }
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.2'
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.3.RELEASE")
}
}
plugins {
//id 'org.sonarqube' version '2.5'
//id 'ch.netzwerg.release' version '1.2.5'
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'org.junit.platform.gradle.plugin'
bootJar {
baseName = 'equipment-workorder-api'
version = '0.1.0'
}
// Inject test phases into the main build task
build.dependsOn('test')
jar {
from sourceSets.main.allSource + sourceSets.test.allSource + sourceSets.test.output
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
repositories {
mavenLocal()
maven {
name "libs-release"
url "https://artifactory.company.com/libs-release"
}
maven {
name "libs-snapshot"
url "https://artifactory.company.com/libs-snapshot"
}
maven {
name "libs-remote"
url "https://artifactory.company.com/libs-remote"
}
maven {
name "spring-milestones"
url "http://repo.spring.io/milestone"
}
maven {
name "jitpack.io" // this is for spring-test-junit5, remove once we upgrade to spring 5
url "https://jitpack.io"
}
maven { url "http://repo.maven.apache.org/maven2" }
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
//Spring Boot
compile group: "org.springframework.boot", name: "spring-boot-actuator", version: "1.5.8.RELEASE"
compile group: "org.springframework.boot", name: "spring-boot-configuration-processor", version: "1.5.8.RELEASE"
//Logging
implementation 'org.slf4j:slf4j-api:1.7.25'
implementation 'org.projectlombok:lombok:1.16.16'
compile group: 'log4j', name: 'log4j', version: '1.2.17'
//JUnit / Mockito
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version:'5.0.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version:'5.0.2'
testImplementation group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.0.2")
//Swagger
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
}
}
【问题讨论】:
-
您是否尝试更改执行器的版本?一方面,您拥有:
[...] spring-boot-gradle-plugin:2.0.3.RELEASE,而在依赖项中:[...] "spring-boot-actuator", version: "1.5.8.RELEASE"。 -
我试过这个依赖项 { classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.2' classpath("org.springframework.boot:spring-boot-gradle-plugin: 1.5.8.RELEASE") }
-
得到同样的结果
-
我建议将
debug = true添加到您的应用程序属性中,您应该会看到自动配置报告。您应该看到HealthEndpointAutoConfiguration被启用,或者如果它没有被有条件地启用的原因
标签: spring-boot spring-boot-actuator