1 在application.properties中添加

android.name=Tim

android.password=123456

新建一个保存该Setting的配置类,

@ConfigurationProperties(prefix="android")

public class AndroidSettings {

private String name;

private String password;

//setters and getters

......

}

2 在自己的properties文件中添加

android.name=Tim

android.password=123456

@Component

@PropertySource("classpath:config/android.properties")

@ConfigurationProperties(prefix="android")

public class AndroidSettings {

private String name;

private String password;

//setters and getters

......

}

3 这两种方式都要在Spring boot的入口类上加上@EnableConfigurationProperties

@SpringBootApplication

@EnableConfigurationProperties(AndroidSettings.class)

public class DemoApplication {

public static void  main(String[] args) {

SpringApplication.run(DemoApplication.class, args);

}

}

4 使用定义的properties

@AutoWired

AndroidSettings androidSettings;

最新文章

  1. android开发:深入理解View(一):从setContentView谈起
  2. BZOJ2498 : Xavier is Learning to Count
  3. AWK命令的用法
  4. 电子词典的相关子函数db.c程序
  5. [转载]有了 malloc/free 为什么还要 new/delete ?
  6. Umbraco Form需要引用些客户端dependencies (jquery)
  7. 动态的 css——less
  8. ecshop标签大全 各个页面常用标签大全
  9. Modbus通信协议详解
  10. vue webuploader 组件开发
  11. web@css高级选择器(after,befor用法),基本css样式
  12. Python学习之MacBook Pro中PyCharm安装pip以及itchat
  13. mybatis动态排序
  14. 获取本机IP地址的小脚本
  15. Intellij idea 2017 图标含义
  16. three.js学习:点光源+动画的实现
  17. TLabel的FocusControl属性什麽意思
  18. 配置mysql主从数据库
  19. 核心API的使用(获取两个字符串的最大相同子串)
  20. org.apache.commons.lang.StringUtils

热门文章

  1. 机器学习第2课:单变量线性回归(Linear Regression with One Variable)
  2. jar文件的Eclipse插件安装
  3. EF使用延迟加载的本质原因
  4. WINDOWS 2003系统时间24小时制与12小时显示格式不一致问题与解决
  5. PHP防止sql注入-JS注入
  6. EffectiveJava(9)覆盖equals是总要覆盖hashCode
  7. 【MVC5】使用Autofac实现依赖注入
  8. Php如何使用curl
  9. redmine安装笔记
  10. 浅谈struts2标签中的2个非经常常使用的标签的使用方法(radio和select)