Spring Boot @Getmapping returns a 404 whitelabel error page in a very simple project

I am learning spring boot. I created this super simple project, but I keep getting a 404 Whitelabel error page when I try to return an HTML page with the @GetMapping annotation.

Here is my only controller:

package com.example.springplay;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

public class MainController {
    @GetMapping(value = "/")
    public String hello(){
        return "hello";

Here is the spring application:

package com.example.springplay;

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

public class SpringplayApplication {

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


Here is the directory

Here is the hello.html page:

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <h1>hello world</h1>

The hello.html page is in the resources/templates folder, I don’t know what’s going on. I copied this part which has the exact same structure from another working project, yet mine just gives me this Whitelabel error page.


Move hello.html to static folder in resource and change controller like this:

    @GetMapping(value = "/")
    public String hello(){
        return "hello.html";

or like this:

    @GetMapping(value = "/")
    public ModelAndView  hello(){
        ModelAndView modelAndView = new ModelAndView();
        return modelAndView;