zoukankan      html  css  js  c++  java
  • Spring随笔(07)

    1、属性占位符(property-placehold)

      第1步 引入context命名空间;

         第2步 提供properties配置文件;

         第3步 通过<context:property-placeholder/>找到配置文件

         第4步 在applicationContext.xml中设置占位符

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation=" http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-4.1.xsd
        default-lazy-init="false">
    
        <!-- 
    配置从哪里找属性的key
    system-properties-mode="NEVER":不使用系统的默认属性,如username在系统中的值是Administrator,
    如果配置文件中username=root,但是没有配置system-properties-mode="NEVER",root将被覆盖为Administrator
    --> <context:property-placeholder location="classpath:db.properties"/> <!-- 数据源配置 --> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">      <property name="driverClassName" value="${driverClassName}" /> <property name="url" value="${url}" /> <property name="username" value="${username}" /> <property name="password" value="${password}" /> <property name="initialSize" value="${initialSize}" /> </bean> </beans>

    db.properties文件配置省略

  • 相关阅读:
    安装Redis
    IntelliJ IDEA 2016.1 创建Maven Java Web项目(图解)
    MongoDB入门
    Oracler的锁概念
    Oracle 数据类型
    《锋利的jQuery》随笔(一)
    IList<T>之 First【学习笔记之Linq】
    入驻新园子
    使用nodejs下载风景壁纸
    nodejs爬取博客园的博文
  • 原文地址:https://www.cnblogs.com/luomsg/p/6425177.html
Copyright © 2011-2022 走看看