0

I created a simple spring boot project and a react app. In src/main/java/com/example/ i have DemoApplication.java and DemoController.java:

DemoApplication:

package com.example;

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

@SpringBootApplication
public class DemoApplication {

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

DemoController:

package tutorial;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class DemoController {

    @RequestMapping(value = "/")
    public String index() {
        return "index.html";
    }
}

In src/main/resources/static/index.html:

<!DOCTYPE html>
<html>
<head>
    <title>React + Spring</title>
    </head>
    <body>
    </body>
    </html>

However when I start the server I see:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Thu Apr 27 23:30:46 EEST 2017
There was an unexpected error (type=Not Found, status=404).
No message available
georgiana_e
  • 1,809
  • 10
  • 35
  • 54
  • Check this [Spring Boot - mapping static index](http://stackoverflow.com/questions/27381781/java-spring-boot-how-to-map-my-app-root-to-index-html) - possible duplicity – Matej Marconak Apr 27 '17 at 20:53
  • Possible duplicate of [Java Spring Boot: How to map my app root (“/”) to index.html?](http://stackoverflow.com/questions/27381781/java-spring-boot-how-to-map-my-app-root-to-index-html) – Matej Marconak Apr 27 '17 at 20:54
  • It worked by putting index.html in the static folder. – georgiana_e Apr 27 '17 at 21:45

0 Answers0