关于@PropertySources注解的理解:http://www.imooc.com/article/252889?block_id=tuijian_wz

public interface PropertySources extends Iterable<PropertySource<?>> {

	/**
* Return a sequential {@link Stream} containing the property sources.
* @since 5.1
*/
default Stream<PropertySource<?>> stream() {
return StreamSupport.stream(spliterator(), false);
}
/**
* Return whether a property source with the given name is contained.
* @param name the {@linkplain PropertySource#getName() name of the property source} to find
*/
boolean contains(String name); /**
* Return the property source with the given name, {@code null} if not found.
* @param name the {@linkplain PropertySource#getName() name of the property source} to find
*/
@Nullable
PropertySource<?> get(String name);
这就是PropertySources的接口,那么它的实现类在哪里?是MutablePropertySources,
}

  PropertySources是由工厂类生成的,看看DefaultPropertySourceFactory

public class DefaultPropertySourceFactory implements PropertySourceFactory {

    @Override
public PropertySource<?> createPropertySource(@Nullable String name, EncodedResource resource) throws IOException {
return (name != null ? new ResourcePropertySource(name, resource) : new ResourcePropertySource(resource));
} }

然后又调用ResourcePropertySource类,在该类下,实现了对配置文件的加载loadProperties(resource).

public class ResourcePropertySource extends PropertiesPropertySource {

	/** The original resource name, if different from the given name. */
@Nullable
private final String resourceName; /**
* Create a PropertySource having the given name based on Properties
* loaded from the given encoded resource.
*/
public ResourcePropertySource(String name, EncodedResource resource) throws IOException {
super(name, PropertiesLoaderUtils.loadProperties(resource));
this.resourceName = getNameForResource(resource.getResource());
}

  剩下的就是java的文件的加载过程,细节就不再讨论了

springboot中Properties注解的实现的更多相关文章

  1. Springboot中PropertySource注解的使用

    https://blog.csdn.net/qq_30739519/article/list/3 注解 https://blog.csdn.net/qq_30739519/article/detail ...

  2. SpringBoot 中常用注解

    本篇博文将介绍几种SpringBoot 中常用注解 其中,各注解的作用为: @PathVaribale 获取url中的数据 @RequestParam 获取请求参数的值 @GetMapping 组合注 ...

  3. SpringBoot 中常用注解@PathVaribale/@RequestParam/@GetMapping介绍

    SpringBoot 中常用注解@PathVaribale/@RequestParam/@GetMapping介绍 本篇博文将介绍几种如何处理url中的参数的注解@PathVaribale/@Requ ...

  4. SpringBoot 中常用注解@Controller/@RestController/@RequestMapping的区别

    SpringBoot中常用注解@Controller/@RestController/@RequestMapping的区别 @Controller 处理http请求 @Controller //@Re ...

  5. SpringBoot 中常用注解@Controller/@RestController/@RequestMapping介绍

    原文 SpringBoot 中常用注解 @Controller/@RestController/@RequestMapping介绍 @Controller 处理http请求 @Controller / ...

  6. springboot中常用注解总结

    1.@RestController(组合注解):标注在类上,等价于@Controller和@Responsebody @Controller:将该类标记为Controller层的类,并且注入到Spri ...

  7. SpringBoot中常见注解含义总结

    @RestController @RestController被称为一个构造型(stereotype)注解.它为阅读代码的开发人员提供建议.对于Spring,该类扮演了一个特殊角色.它继承自@Cont ...

  8. SpringBoot中常用注解@Controller/@RestController/@RequestMapping的区别

    @Controller 处理http请求 @Controller //@ResponseBody public class HelloController { @RequestMapping(valu ...

  9. SpringMVC 和SpringBoot中的注解是如何起作用的,如何实现的

    SpringMVC源码解读 - HandlerMapping - RequestMappingHandlerMapping初始化   https://www.cnblogs.com/leftthen/ ...

随机推荐

  1. 基于ubuntu的docker安装

    系统版本:Ubuntu16.04 docker版本:18.02.0 Ubuntu 系统的内核版本>3.10(执行 uname -r 可查看内核版本)   在安装前先简单介绍一下docker,按照 ...

  2. seq_file学习(2)—— seq_file

    li {list-style-type:decimal;}ol.wiz-list-level2 > li {list-style-type:lower-latin;}ol.wiz-list-le ...

  3. Java知识回顾 (9) 同步、异步IO

    一.基本概念 同步和异步: 同步和异步是针对应用程序和内核的交互而言的. 同步指的是用户进程触发IO 操作并等待或者轮询的去查看IO 操作是否就绪: 而异步是指用户进程触发IO 操作以后便开始做自己的 ...

  4. 常见爬虫/BOT对抗技术介绍(一)

    爬虫,是大家获取互联网公开数据的有效手段.爬虫.反爬虫技术.反-反爬虫技术随着互联网的不断发展,也在不断发展更新, 本文简要介绍现代的爬虫/BOT对抗技术,如有疏漏,多谢指正! 一.反爬虫/BOT技术 ...

  5. [PHP] 多表外连接性能测试及优化

    原文:https://blog.csdn.net/tang_huan_11/article/details/41925639 版权声明:本文为博主原创文章,转载请附上博文链接!

  6. Javascript 字符串(一)常见函数使用

    一.js字符串示例1 <script type="text/javascript"> var strobject = new String('123abc123abc' ...

  7. 实时查看docker容器日志

    实时查看docker容器日志 $ sudo docker logs -f -t --tail 行数 容器名 例:实时查看docker容器名为s12的最后10行日志 $ sudo docker logs ...

  8. System.IO.File.WriteAllText("log.txt", "dddd");

    System.IO.File.WriteAllText("log.txt", "dddd");

  9. 【C++】解析C++运行环境的搭建

    在本篇文章中,笔者会谈谈如何搭建C++的运行环境.在不同操作系统中,运行C++编译器的命令也各不相同,最常用的编译器是GNU编译器(Linux系统)和微软Visual Studio编译器(Window ...

  10. Android jks 签名文件 生成

    Android Win7 上使用cmd生成Jks cmd 命令 C:\Program Files\Java\jre1.8.0_111\bin>keytool -genkeypair -alias ...