Springboot configuration static resource directory

Programmer light 2022-02-13 07:58:48 阅读数:191

springboot configuration static resource directory

In our daily development , Need configuration js、css、 Access the directory of static resources such as pictures , Yes, of course , These resources are best through nginx The distribution is more appropriate , Not much here , Let's see SpringBoot How to configure static resource directory

First create the project

  Two 、SpringBoot Default static file configuration

spring-boot-autoconfigure This depends on the files in the package :spring-configuration-metadata.json In file
spring.web.resources.static-locations With this parameter, you can see several of the default configurations :
classpath:META-INF/resources/
classpath:resources/
classpath:static/
classpath:public/

 

 

We are in the project resources Let's create a few folders , And put it on 4 A picture ,1/2/3/4 Pictures can be accessed

 

 

copyright:author[Programmer light],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130758462794.html