可以做淘宝推广的网站吗,电脑没有网怎么升级wordpress,通用企业手机网站模板,什么叫app是什么意思这就是自动装配的原理 1) .SpringBoot启动会加载大量的自动配置类 2)、我们看我们需要的功能有没有在SpringBoot默认写好的自动配置类当中; 3)、我们再来看这个自动配置类中到底配置了哪些组件;(只要我们要用的组件存在在其中#xff0c;我们就不需要再手动配置了) 4)、给容器…这就是自动装配的原理 1) .SpringBoot启动会加载大量的自动配置类 2)、我们看我们需要的功能有没有在SpringBoot默认写好的自动配置类当中; 3)、我们再来看这个自动配置类中到底配置了哪些组件;(只要我们要用的组件存在在其中我们就不需要再手动配置了) 4)、给容器中自动配置类添加组件的时候会从properties类中获取某些属性。我们只需要在配置文件中指定这些属性的值即可; xxxxAutoConfigurartion:自动配置类;给容器中添加组件 xxxxProperties:封装配置文件中相关属性;
Thymeleaf
Spring Boot 推荐使用 Thymeleaf 作为其模板引擎。SpringBoot 为 Thymeleaf 提供了一系列默认配置项目中一但导入了 Thymeleaf 的依赖相对应的自动配置 ThymeleafAutoConfiguration 就会自动生效因此 Thymeleaf 可以与 Spring Boot 完美整合 dependencygroupIdorg.thymeleaf/groupIdartifactIdthymeleaf/artifactIdversion3.0.15.RELEASE/version
/dependency ThymeleafAutoConfiguration 使用 EnableConfigurationProperties 注解导入了 ThymeleafProperties 类该类包含了与 Thymeleaf 相关的自动配置属性其部分源码如下。
纯文本复制 ConfigurationProperties(prefix spring.thymeleaf)public class ThymeleafProperties {private static final Charset DEFAULT_ENCODING;public static final String DEFAULT_PREFIX classpath:/templates/;public static final String DEFAULT_SUFFIX .html;private boolean checkTemplate true;private boolean checkTemplateLocation true;private String prefix classpath:/templates/;private String suffix .html;private String mode HTML;private Charset encoding;private boolean cache;...} Thymeleaf中的一些用法 根据以上配置属性可知Thymeleaf 模板的默认位置在 resources/templates 目录下默认的后缀是 html即只要将 HTML 页面放在“classpath:/templates/”下Thymeleaf 就能自动进行渲染。 与 Spring Boot 其他自定义配置一样我们可以在 application.properties/yml 中修改以 spring.thymeleaf 开始的属性以实现修改 Spring Boot 对 Thymeleaf 的自动配置的目的。