SpringBoot访问静态文件
一、集成到默认地址
默认地址
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>