关于@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下实验安装

    1.Ubuntu下安装sublime : http://www.linuxidc.com/Linux/2015-01/112137.htm 2.http://www.linuxidc.com/Linu ...

  2. java内部类(一)

    内部类(一) 一.定义: 内部类就是定义在另一个类内部的类,与之对应,包含内部类的类就是外部类. 二.作用: 1.内部类提供更好的封装,可以把内部类隐藏在外部类之内,不允许同一个包之中的其他类访问该类 ...

  3. Accounting Calendar template

    SELECT INITCAP (TO_CHAR (TO_DATE (&year || '-' || LPAD (ROWNUM, 2, '0'), 'yyyy-mm'), 'MON', 'NLS ...

  4. Multiple Tasks Z

    public static async Task executeParallel<T>(this IEnumerable<T> items, int limit, Func&l ...

  5. Unsupervised pre-training

    如图所示: 假设你想要解决一个复杂的任务,你没有太多的标记的训练数据,但不幸的是,你不能找到一个类似的任务训练模型. 不要失去所有希望! 首先,你当然应该尝试收集更多的有标签的训练数据,但是如果这太难 ...

  6. 这13个开源GIS软件,你了解几个?【转】

    泰伯网有看点的空间地理信息资讯都在这,你还在等什么? 这些开源GIS软件,你了解几个?本文内容部分来源于一份罗列了关于GIS软件应用的文章,笔者将其编译整合. 地理信息系统(Geographic In ...

  7. MYSQL常用的性能指标总结和归纳

    (1) QPS(每秒Query量)QPS = Questions(or Queries) / uptimemysql> show global status like 'Question%';m ...

  8. ubuntu16.04 npm安装

    $ sudo apt-get install python-software-properties $ curl -sL https://deb.nodesource.com/setup_6.x | ...

  9. spring拦截器中使用spring的自动注入

    需要在spring的拦截器中使用自定义的服务,这要就设计到将服务注入到拦截器中.网上看的情况有两种: 1. @Configuration public class OptPermissionHandl ...

  10. 浅谈 CSS 预处理器: 为什么要使用预处理器?

    CSS 自诞生以来,基本语法和核心机制一直没有本质上的变化,它的发展几乎全是表现力层面上的提升.最开始 CSS 在网页中的作用只是辅助性的装饰,轻便易学是最大的需求:然而如今网站的复杂度已经不可同日而 ...