我有一个Spring Boot Rest API项目-我无法使Spring Boot执行器/ 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'
}
}
答案 0 :(得分:0)
当您想通过HTTP获取运行状况时,可能需要添加此依赖项并尝试一下:
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.8.RELEASE'
答案 1 :(得分:0)
您需要从 application.yml 文件公开端点才能看到执行器/健康端点结果。 在 Gradle 中,我们为此使用 application.yml 文件,因此只需在此文件中写入以下配置:
management:
endpoints:
web:
exposure:
include: "*" #<2>
endpoint:
health:
show-details: ALWAYS
您可以随时排除您希望排除的任何端点。