Spring Boot无法找到index.html

时间:2018-11-02 02:01:09

标签: reactjs spring-boot

嗨,我有多个Maven Spring Boot项目。 Ui(react js)是从不同的jar中提供的。我可以在运行npm start时运行UI,但是当我将Spring Boot jar和UI jar部署到tomcat服务器中时,我无法加载index.hmtl。任何帮助表示赞赏。服务器启动时,我添加了一个contoller以重定向到索引页面。

1 个答案:

答案 0 :(得分:2)

您需要将静态文件放置在src/main/resouces/static/目录下。我认为您不需要通过Controller访问index.html。看看Spring启动文档https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-static-content