Spring Boot Problem because of LSP (failed to refresh live data from process ...)

Viewed 3830

I just began to use spring boot. My new created project doesn´t work succesfully. I want to run the spring boot app with "run as Spring Boot App" but I´ve got the same error as @Vinay Vaishnav. I´ve tried everything covered in the replies.

My first error was: Failed to refresh live data from process ...

LSP ERROR Before Changes

After that I included following dependency to the pom.xml:

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

Because of the added dependency the error is gone but then i´ve got 404

WhiteLabel Error

I also added the livereload devtools in the applicationProperties. It doesn´t matter if this line is added or not.

That´s my code for now:

AppConfiguration.java:

package com.example.demo;

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

public class AppConfiguration {

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

applicationProperties:

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

My versions:

  • Apache Maven 3.6.3
  • Spring Boot 2.2.6
  • JDK 13.0.2
2 Answers

It's better to disable the process tracking in STS preferences, instead of adding the dependency, if the project not actually uses it.

enter image description here

You are confusing how to write down your classes.

First, @RestController must be in a class that is going to control the requests. (In your case it should go in AppConfiguration)

With this change it should work.

And you should change the name of your class to AppController. (Just to be more consistent with what the class does)

Related