我正在尝试使用create-react-app
和Spring Boot创建一个简单的Web应用程序,但是Spring在资源中找不到index.html
。Spring Boot和React无法加载index.html
阵营的build
文件夹是由maven-resources-plugin
复制到target
:
这是我的项目结构:
控制器:
@Controller
public class BasicController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index() {
return "index";
}
}
GET请求localhost:8080
回报404
。你能指点我我在哪里弄错了。
UPDATE:
管理,使其通过改变阵营的建立输出目录中的Maven插件来 ${basedir}/src/main/resources/META-INF/resources
和return "index"
到return index.html
工作。