[英]getting "Whitelabel Error Page" running actuator health and mappings urls
I am starting with spring boot, running a demo spring web starter project, I was checking the spring actuator functionality by calling http://localhost:8080/mappings and http://localhost:8080/health ... It's giving me the "Whitelabel Error Page"... the log is not showing anything I am starting with spring boot, running a demo spring web starter project, I was checking the spring actuator functionality by calling http://localhost:8080/mappings and http://localhost:8080/health ... It's giving me the “Whitelabel 错误页面”...日志未显示任何内容
the project is a very simple boot application created in STS with one @RestController
which is working fine该项目是在 STS 中创建的一个非常简单的启动应用程序,其中一个
@RestController
运行良好
Main class:主class:
@SpringBootApplication
public class DemoApplication {
public static HashMap<Long,Student> hmStudent;
public static void main(String[] args) {
//dummt code
SpringApplication.run(DemoApplication.class, args);
}
}
Rest Controller: Rest Controller:
import java.util.HashMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.example.demo.DemoApplication;
import com.example.demo.entities.Student;
@RestController
@RequestMapping(value="/rest/student")
class StudentService{
@RequestMapping(value="/",method = RequestMethod.GET)
public HashMap<Long,Student> getAllStudents(){
return DemoApplication.hmStudent;
}
.
.
.
.
}
application properties:应用属性:
spring.datasource.url=jdbc:oracle:thin:@localhost:ibmwas
spring.datasource.username=u
spring.datasource.password=p
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
pom.xml pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jta-atomikos</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
What is the problem and how can I the logs be more descriptive有什么问题,我怎样才能让日志更具描述性
As of Spring Boot 2.0.0.RELEASE the default prefix for all endpoints is /actuator
So if you want to check the health of an application, you should go to /actuator/health
从 Spring Boot 2.0.0.RELEASE 开始,所有端点的默认前缀是
/actuator
所以如果你想检查应用程序的健康状况,你应该去/actuator/health
To make an actuator endpoint available via HTTP, it needs to be both enabled and exposed.要通过 HTTP 使执行器端点可用,它需要同时启用和公开。
By default:默认情况下:
only the /health
and /info
endpoints are exposed.仅暴露
/health
和/info
端点。
all endpoints but /shutdown
are enabled (only /health and /info are exposed)启用除
/shutdown
所有端点(仅暴露 /health 和 /info)
To expose all endpoints you have to add the following line into application.properties
:要公开所有端点,您必须将以下行添加到
application.properties
:
management.endpoints.web.exposure.include=*
I had the same problem.我有同样的问题。 After some trial and error, i got the actuator output when i hit http://localhost:8080 on the browser, it took me to the HAL browser .
经过反复试验,当我在浏览器上点击http://localhost:8080时,我得到了执行器输出,它把我带到了 HAL 浏览器。 From the HAL's explorer, i typed actuator, which took me to http://localhost:8080/browser/index.html#http://localhost:8080/actuator and this is where are all the details I was looking for at http://localhost:8080/application was present.
从HAL的探险家,我输入驱动器,其中带我去的http://本地主机:8080 /浏览器/ index.html的#HTTP://本地主机:8080 /驱动器,这是哪里都是我一直在寻找的细节HTTP ://localhost:8080/application存在。
Note Spring boot version that I am using is : 2.0.6 SNAPSHOT.注意我使用的 Spring Boot 版本是:2.0.6 SNAPSHOT。
And, in the application.properties, i had added management.security.enabled=false.而且,在 application.properties 中,我添加了 management.security.enabled=false。 w/o this i could see very minimal info.
没有这个,我可以看到非常少的信息。
spring.mvc.throw-exception-if-no-handler-found=true
spring.resources.add-mappings=false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.