【发布时间】:2020-09-06 20:27:18
【问题描述】:
我有一个使用 ReactJs 作为前端库的 Spring Boot 应用程序 (2.2.6.RELEASE)。 我在 application.properties 中配置了一个自定义上下文路径和 spring.mvc 属性,如下所示:
server.servlet.context-path=/gui
spring.mvc.view.prefix: /static/dist/
spring.mvc.view.suffix: .html
spring.mvc.static-path-pattern=/static/**
Webpack 用于在 src/main/resources/static/dist 中构建包和 index.html。项目结构如下所示:
我需要能够从
访问 index.html本地主机:8080/gui
使用这些设置,但由于某种原因它无法启动。但是,如果我尝试使用
localhost:8080/gui/static/dist/index.html
资源已到达。如何配置 Spring 以按照我的意愿提供资源?
【问题讨论】:
-
spring.resources.static-locations=classpath:/static/dist/
-
@OlehKurpiak 帮助了我。谢谢!
标签: java spring spring-boot spring-mvc