关于@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. IDEA 下载 和 安装 22

    1. IDEA 下载 网址     pttps://www.jetbrains.com IDEA      优点  :高度集成企业软件工程的概念(svn, git) 缺点: 破解存在在法律风险 ; E ...

  2. Mac/Ubuntu下的数据建模工具PDMan,替代PowerDesigner

    PowerDesigner我使用过用Wine在Linux和Mac下用,但总有些缺陷,用Navicat却发觉没有Linux版本的: 一般关心的问题主要有如下: 1.数据库的关系设计图. 2.导出数据库脚 ...

  3. 编写CentOS的System V init启动脚本

    系统本身自带了说明,在/usr/share/doc/initscripts-(*)/sysvinitfiles,内容如下: 所有System V init脚本都命名为/etc/rc.d/init.d/ ...

  4. 【总结】瞬时高并发(秒杀/活动)Redis方案

    1,Redis 丰富的数据结构(Data Structures) 字符串(String) Redis字符串能包含任意类型的数据 一个字符串类型的值最多能存储512M字节的内容 利用INCR命令簇(IN ...

  5. performSelector may cause a leak because its selector is unknown

    转自:http://www.jianshu.com/p/6517ab655be7 问题 我在 ARC 模式下编译出了这个 warning: "performSelector may caus ...

  6. .Net转Java.06.字符串的split的区别

    在Java遇到了将类似“1|2|3|4”的字符串分隔为数组的功能 这种问题能难倒有着十多年开发经验的的.NET码农? // Java代码 String s="1|2|3"; Str ...

  7. springboot拦截器@Autowired为null解决

    问题原因 拦截器加载的时间点在springcontext之前,所以在拦截器中注入自然为null 文件解决 在spring配置文件中这样写 @Bean public HandlerInterceptor ...

  8. java后台服务器启动脚本

    最近由于经常在项目上线或者调试中启动服务,由于要设置环境变量这些,所以为了方便写了个启动脚本,希望能够帮助大家,也算是给自己做个小笔记: example_project_start.sh: # /bi ...

  9. pip安装pycrypto报错:Microsoft Visual C++ 14.0 is required. 和 SSLError: HTTPSConnectionPool的解决办法

    今天本打算把[Python3爬虫]网易云音乐爬虫 的代码敲一遍, 但是在安装pycrypto老是报错, 由于我计算是win10, 并且也有vs2017 python3环境下安装pycrypto的一些问 ...

  10. C# CancellationTokenSource和CancellationToken的实现

    微软关于CancellationTokenSource的介绍很简单,其实CancellationTokenSource的使用也很简单,但是实现就不是那么简单了,我们首先来看看CancellationT ...