我有一个spring boot项目,位于路径“c:\ personal projects\spring”中,我希望它能用于浏览器名为index.html的静态html文件,该文件位于“c:\ personal projects\game\build”中。
因此,我编写了以下代码:
@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错误。
你知道我做错了什么吗?