SpringBoot访问静态文件
原创
©著作权归作者所有:来自51CTO博客作者小大宇51CTO的原创作品,请联系作者获取转载授权,否则将追究法律责任
一、集成到默认地址
默认地址
classpath:/META-INF/resources/","classpath:/resources/", "classpath:/static/", "classpath:/public/
配置该地址:
spring:
resources:
static-locations: 自定义目录
二、自定义POM文件
如果不想配置 application.yaml文件的话,也可以把文件放到 src/main/webapp目录下,然后在pom.xml文件中加入如下配置。这样打包的话,也会把文件打到SpringBoot约定的静态文件路径【/META-INF/resources】中
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</resource>
<resource>
<directory>src/main/webapp</directory>
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>