java - 基本的 Spring Boot 应用程序不起作用,显示:无法从进程 xxxx 刷新实时数据
问题描述
我是弹簧靴的初学者。我初始化了一个新项目并尝试运行它,但它无法成功运行。当我将它作为 Spring Boot 应用程序运行时,它开始执行。在底部的编译器/状态栏中,它显示正在处理和重试。它最多上升 10 次并引发以下错误:
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>
解决方案
我在 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>
推荐阅读
- php - 按月份查询SQL
- javascript - 反应本机(Android) - RN-fetch-blob 坏 base64
- excel - 只需要从访问数据库中的查询中提取/导出 2 列到 excel
- docker - Docker 私有 IP 在外部网络上泄漏
- python - 分组后从列中提取数据到新列
- jquery - Laravel 7 $.ajax 请求未执行
- android-studio - 当我在我的设备上运行颤振应用程序时出现错误
- python - 在 pyqt5 GUI 中从 qtablewidgets 和绘图创建 pdf 报告
- javascript - 选择 React 中 Google Charts 上工具提示显示的信息
- python - 最终结果中的问题(Python)