spring.resources.static-locations在项目文件中找不到用法
时间: 2024-04-25 07:22:06 浏览: 29
在Spring Boot项目中,可以使用`spring.resources.static-locations`属性来指定查找本地静态文件的位置。该属性可以在项目的配置文件(如application.properties或application.yml)中进行配置。通过配置该属性,可以告诉Spring Boot在哪些目录下查找静态文件。
例如,如果想要在项目的根目录下的static文件夹和public文件夹中查找静态文件,可以在配置文件中添加以下配置:
```
spring.resources.static-locations=classpath:/static/,classpath:/public/
```
这样,当访问静态资源时,Spring Boot会在这两个目录下查找对应的文件。如果找到匹配的文件,就会返回给客户端。
需要注意的是,`spring.resources.static-locations`属性的值可以是一个或多个目录路径,多个路径之间使用逗号进行分隔。路径可以是相对路径或绝对路径,也可以是classpath路径。
希望这个解答对你有帮助!\[1\]\[2\]\[3\]
#### 引用[.reference_title]
- *1* [spring.mvc.static-path-pattern和spring.resources.static-locations](https://blog.csdn.net/baidu_38225647/article/details/109464223)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [Spring Boot配置静态资源的地址与访问路径(spring.mvc.static-path-pattern和spring.web.resources.static-...](https://blog.csdn.net/weixin_38924500/article/details/109739021)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)