首页 > 解决方案 > 基本的 Spring Boot 应用程序不起作用,显示:无法从进程 xxxx 刷新实时数据

问题描述

我是弹簧靴的初学者。我初始化了一个新项目并尝试运行它,但它无法成功运行。当我将它作为 Spring Boot 应用程序运行时,它开始执行。在底部的编译器/状态栏中,它显示正在处理和重试。它最多上升 10 次并引发以下错误:

无法从进程 xxxx 刷新实时数据

更多细节在这里

TanmayTestApplication.java

package com.example.tanmay_test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class TanmayTestApplication {

    public static void main(String[] args) {
        SpringApplication.run(TanmayTestApplication.class, args);
    }
}

DemoControler.java

package com.example.cntr;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

@RestController
public class DemoControler {

    @RequestMapping(path = "/index")
    public String index() {
        return "By Tanmay!";
    }   
}

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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>tanmay_test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>tanmay_test</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

标签: javaspringspring-bootmaven

解决方案


我在 STS 中遇到了同样的问题,并尝试了不同的方法来解决它。以下对弹簧执行器的依赖使该问题消失了,但是弹簧执行器的要点提供了比这更多的功能。要了解更多信息,请单击https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html

应将依赖项添加到您的 pom.xml 文件中

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

推荐阅读