zoukankan      html  css  js  c++  java
  • 【Autofac打标签模式】PropertySource和Value

    【 Autofac打标签模式】开源DI框架扩展地址:

    https://github.com/yuzd/Autofac.Annotation/wiki

    PropertySource 指定数据源

    属性说明
    Path 文件路径,看下面的说明
    OrderIndex 文件源排序,越大越先作为查找对象
    Embedded 是否为内嵌资源
    
        [PropertySource("appsettings.json")] //这行也可以直接去掉 因为和默认的一样
        [Component]
        public class Student9
        {
            [Value("${a9}")]
            public string Name { get; set; }
        }
        
    

    image

    image

    • PropertySource的path可以指定为json 和 xml 文件
    • PropertySource 如果不指定path 默认path为根目录的appsettions.json
    • 如果Path的值为 / 开头 则代表为相对于工程目录
    • 如果设定 Embedded = true 则代表path的值为 内嵌资源的文件名称
    • Path的值也可以为 文件的完整路径

    Value装配数据源里面的值

    • ${xxx} 代表从配置源里面 获取属性名称为xxx的值
    • #{xxx} 代表启动SPEL表达式,xxx里面可以嵌套${yyy}

    image

  • 相关阅读:
    分布式事务
    K8s应用案例介绍——阿里云
    数据库索引的底层原理——b树
    Understanding the GitHub flow
    Code Review
    详解微服务架构
    yarn之package.json
    yarn.lock文件
    Git Api——git开发
    Unit Test —— xUnit.net
  • 原文地址:https://www.cnblogs.com/yudongdong/p/11745725.html
Copyright © 2011-2022 走看看