zoukankan      html  css  js  c++  java
  • SpringBoot配置文件的加载方式

    方式一
    /**

    • 将配置文件中配置的每一个属性的值,映射到这个组件中
    • @ConfigurationProperties:告诉SpringBoot将本类中的所有属性和配置文件中相关的配置进行绑定;
    •  prefix = "person":配置文件中哪个下面的所有属性进行一一映射
      
    • 只有这个组件是容器中的组件,才能容器提供的@ConfigurationProperties功能;

    */
    @Component
    @ConfigurationProperties(prefix = "person")
    public class Test{
    。。。。。。
    。。。。。。。
    }

    方式二
    /**

    • 将配置文件中配置的每一个属性的值,映射到这个组件中
    • @ConfigurationProperties:告诉SpringBoot将本类中的所有属性和配置文件中相关的配置进行绑定;
    •  prefix = "person":配置文件中哪个下面的所有属性进行一一映射
      
    • 只有这个组件是容器中的组件,才能容器提供的@ConfigurationProperties功能;

    */
    @Component
    @ConfigurationProperties(prefix = "person")
    public class Test{
    。。。。。。
    。。。。。。。
    }

    /**

    • 将配置文件中配置的每一个属性的值,映射到这个组件中
    • @ConfigurationProperties:告诉SpringBoot将本类中的所有属性和配置文件中相关的配置进行绑定;
    •  prefix = "person":配置文件中哪个下面的所有属性进行一一映射
      
    • 只有这个组件是容器中的组件,才能容器提供的@ConfigurationProperties功能;
    • @ConfigurationProperties(prefix = "person")默认从全局配置文件中获取值;

    */
    @PropertySource(value = {"classpath:person.properties"})
    @Component
    @ConfigurationProperties(prefix = "person")
    //@Validated
    public class Test{
    ......
    }

  • 相关阅读:
    hbase与Hive的集成
    HBase API操作
    HBase原理
    HBase数据结构
    HBase Shell操作
    HBase简介
    Boxes in a Line
    B
    B. Painting Pebbles
    X
  • 原文地址:https://www.cnblogs.com/hbym/p/15119610.html
Copyright © 2011-2022 走看看