How to resolve the problem related to "Whitelabel Error Page" in a Spring Boot application

BackToReal :

I am trying to execute my new Spring Boot application. The first two classes are:

import org.springframework.boot.autoconfigure.SpringBootApplication;

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

then the servlet Initializer class

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(UbbioneApplication.class);
    }
}

But when I am used to run my application by writing mvn spring-boot:run in the console, I have this message appearing:

Whitelabel Error Page

Could you help me please how to resolve this issue? Thanks in advance.

BackToReal :

I think I have an answer:

I created a controller to my application and I updated my code as following:

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = {"Name_controller_path"})
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Then my controller will look like this:

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

@RestController
public class Appcontroller {

    @RequestMapping(value = "/home", method = RequestMethod.GET)
    String home() {
        return "home";
    }
}

Then use this path to view your execution: http://localhost:8080/home.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=154911&siteId=1