【发布时间】:2018-11-25 17:38:49
【问题描述】:
我有一个 Spring Boot 项目位于路径“C:\Personal Projects\Spring”中,我希望它服务于名为 index.html 的浏览器静态 HTML 文件,该文件位于“C:\Personal Projects\Game\构建”。
因此,我写了如下代码:
@SpringBootApplication
@EnableAutoConfiguration
public class Main {
public static void main(String[] args) throws IOException {
SpringApplication app = new SpringApplication(Main.class);
Properties properties = new Properties();
properties.setProperty("spring.resources.static-locations",
"C:\\Personal Projects\\Game\\build");
app.setDefaultProperties(properties);
app.run(args);
}
}
当我运行程序并为“localhost:8080/index.html”打开浏览器时,我收到 404 错误。
你知道我做错了什么吗?
【问题讨论】:
标签: spring-boot