我创建了一个简单的spring boot项目和一个react应用程序。 在src / main / java / com / example /中有DemoApplication.java和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";
}
}
在src / main / resources / static / index.html中:
<!DOCTYPE html>
<html>
<head>
<title>React + Spring</title>
</head>
<body>
</body>
</html>
然而,当我启动服务器时,我看到:
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