1、配置文件(*.properties)往往通过以下方式注册在Spring IOC中。

    <!-- JDBC配置 -->
<context:property-placeholder location="classpath:mybatis/db.properties"
ignore-unresolvable="true" /> <!-- 微信公众号信息 -->
<context:property-placeholder
location="classpath:wechat/official-account.properties"
ignore-unresolvable="true" /> <!-- 触发器表达式 -->
<context:property-placeholder
location="classpath:wechat/cron-expression.properties"
ignore-unresolvable="true" /> <!-- 其他配置(分页尺寸、访问频率等) -->
<context:property-placeholder
location="classpath:wechat/other.properties"
ignore-unresolvable="true" />

2、在控制层或业务层的类中,通过@Value注解引入其中的某个属性。

/src/main/resources/mybatis/db.properties

# db.properties
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/demo?characterEncoding=UTF-8&useUnicode=true&useSSL=false&allowMultiQueries=true
jdbc.username=root
jdbc.password=root

io.spldeolin.demo.controller.OneController

@Controller
public class DepartmentController { @Value("${jdbc.password}")
private String a; // Others ignore }

3.DEBUG

最新文章

  1. dataTransfer.getData()在dragover,dragenter,dragleave中无法获取数据的问题
  2. H-Basis/SG/SH GI Relighting
  3. PHP+MD5
  4. [daily][network] NAT原理(转)
  5. NSBundle UIImageView &amp;UIButton
  6. Windows Azure 基本操作手册
  7. [React Native] Basic iOS Routing -- NavigatorIOS
  8. Yum安装Memcache
  9. Weblogic的集群
  10. POJ2299--树状数组求逆序数
  11. AFNetWorking常用方法
  12. Jvm原理剖析与调优之内存结构
  13. ActiveMQ + NodeJS + Stomp 极简入门
  14. EsayUi中常用的属性和方法总结
  15. Windows下Caffe实现图像分类
  16. angular raido checkbox select取值
  17. MySQL open_tables和opened_tables
  18. smartctl 检测磁盘信息
  19. Vue自定义指令,ref ,sync,slot
  20. How to Pronounce Work vs. Walk

热门文章

  1. Asp.Net Mvc Area二级域名
  2. 一、openfeign的自动配置
  3. 用ajax和PHP实现简单的流程管理
  4. 从SAP社区上的一篇博客开始,聊聊SAP产品命名背后的那份情怀
  5. linux管道和重定向
  6. Android笔记(十二)AndroidManiFest.xml
  7. Jenkins管理插件
  8. 【蜂窝】at+qcfg=&quot;band&quot;的计算和使用
  9. python(列表及列表的相关操作、元组和range)
  10. 1127 模型层orm表操作