首页 > 解决方案 > 由于 LSP 导致的 Spring Boot 问题(无法从进程中刷新实时数据......)

问题描述

我刚开始使用spring boot。我新创建的项目无法成功运行。我想用“作为 Spring Boot App 运行”来运行 Spring Boot 应用程序,但我遇到了与 @Vinay Vaishnav 相同的错误。我已经尝试了回复中涵盖的所有内容。

我的第一个错误是:无法从进程中刷新实时数据...

更改前的 LSP 错误

之后,我在 pom.xml 中包含以下依赖项:

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

由于增加了依赖,错误消失了,但是我得到了 404

白标错误

我还在 applicationProperties 中添加了 livereload devtools。是否添加此行无关紧要。

这是我现在的代码:

AppConfiguration.java:

package com.example.demo;

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

public class AppConfiguration {

    @RequestMapping("/hello") 
    public String hello() {
        return  "Hello World";
    }
}

应用程序属性:

spring.devtools.livereload.enabled=true
server.port=8081

HelloWorldApplication.java:

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RestController;


@RestController
@SpringBootApplication
public class HelloWorldApplication {

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

我的版本:

标签: javaspringspring-bootliskov-substitution-principle

解决方案


如果项目没有实际使用它,最好在 STS 首选项中禁用进程跟踪,而不是添加依赖项。

在此处输入图像描述


推荐阅读