Spring Boot的资源加载路径和classpath问题
1、Spring Boot默认加载文件的路径
- /META-INF/resources/
- /resources/
- /static/
- /public/
也可以从Spring Boot的源码看到:
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { "classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/" };
2、Classpath含义
- 存放各种资源配置文件 application.yml
- 存放模板文件
- 存放class文件对应的是项目开发时的src目录编译文件
3、总结
classpath就是springboot定位资源的入口