Eclipse build (ii) springboot project directory springboot

SpringBoot directory and file structure recommended by the official directory specification

1, the directory
src / main / java: Code stored
src / main / Resources
static: storing static files, such as css, js, image, (access method HTTP: // localhost: 8080 / JS / main.js)
Templates: Static storage page JSP, HTML, tpl
config: to store configuration files, application.properties
Resources:

2, the introduction of dependent Thymeleaf
<dependency>
<the groupId> org.springframework.boot </ the groupId>
<the artifactId> Starter-Spring-Boot-Thymeleaf </ the artifactId>
</ dependency>
Note: If this does not introduce dependencies, html files it should be placed inside a folder loaded by default,
such as resources, static, public this several folders can be accessed

3, load order of the same file, static resource files
Spring Boot default one by one resources> static> public inside to find whether the corresponding resource exists from META / resources>, if there is a direct return.

4, the default configuration
1) official website address: https: //docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc -static-content

2)spring.resources.static-locations = classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/

5, large companies generally static resource files stored in the CDN, hit the nearest node, particularly fast response

 

Create a directory, verify that static pages can be accessed:

 Verify static files can be accessed:

 

Guess you like

Origin www.cnblogs.com/aaronRhythm/p/10951381.html