当前位置: 首页 > 知识库问答 >
问题:

获取“白标签错误页”运行执行器运行状况和映射URL

欧阳俊逸
2023-03-14

我从Spring Boot开始,运行一个演示spring web starter项目,通过调用http://localhost:8080/mappings和http://localhost:8080/health来检查spring执行器的功能...它给我的是“白标签错误页”...日志没有显示任何内容

该项目是一个非常简单的启动应用程序,在STS中创建,使用一个运行良好的@RestController

主类:

@SpringBootApplication
public class DemoApplication {

    public static HashMap<Long,Student> hmStudent;

    public static void main(String[] args) {
        //dummt code
          SpringApplication.run(DemoApplication.class, args);
    }
}

Rest控制器:

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;
   }
.
.
.
.
}

应用程序属性:

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
<?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>

共有1个答案

芮岳
2023-03-14

从Spring Boot 2.0.0.release开始,所有endpoint的默认前缀都是/acture,所以如果您想检查应用程序的运行状况,应该转到/acture/healt

要使执行器endpoint通过HTTP可用,它需要同时启用和公开。

默认情况下:

启用了/shutdown以外的所有endpoint(仅公开/health和/info)

要公开所有endpoint,必须在application.properties中添加以下行:

management.endpoints.web.exposure.include=*
 类似资料:
  • 我从spring boot开始,运行一个演示spring web starter项目,我通过调用http://localhost:8080/mappings和http://localhost:8080/health来检查spring actuator的功能...它给了我一个“whitelabel错误页”...日志没有显示任何内容 这个项目是一个用STS创建的非常简单的引导应用程序,只有一个,运行良

  • 当我使用ide运行我的springboot应用程序时,它工作正常。 但当我运行它的jar时,我得到了白标签错误页面。 白标签错误页面 此应用程序没有 /error的显式映射,因此您将此视为后备。 2018年10月9日星期二15:42:47出现意外错误(类型=未找到,状态=404)/WEB-INF/views/index。jsp

  • 我在eclipse(juno)中创建了一个简单的hello.jsp程序,当我试图通过run on server来运行这个jsp文件时,得到了以下错误 出现问题, 我已经删除了eclipse&tomcat服务器,然后重新安装。但是仍然得到相同的错误。我尝试选择服务器位置作为使用自定义位置,并给出不同的工作区路径。但什么都不管用。 我使用的是eclipse Juno、apache Tomcat-V6.

  • 我试图在eclipse中使用owlapi创建一个本体,使用owl-osgi-distribution 4.0.2并得到一个Noclassfound错误,与链接中的错误类似 根据我得到的错误: 有了链接中的答案,我明白了我的owlapi文件需要添加,为了解决这个问题,我参考了下面的方法。 http://www.jabenitez.com/2015/08/19/solucionando-el-erro

  • 假设我们有 具有HTTP网关出站服务的客户端节点 具有HTTP网关入站服务的服务器节点 我考虑MSMQ本身在客户端节点上由于某种原因停止的情况。在当前实现中,Rebus HTTP网关将捕获异常。 您如何看待MessageQueueExcpse异常也可以发送到服务器节点并放在错误队列中,而不仅仅是捕获?(错误队列的名称可以从标题中收集) 因此,在没有额外基础设施的情况下,服务器会知道客户端有问题,以