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文件配置省略

  • 相关阅读:
    聊一聊Flutter的setState()
    Flutter + Android 混合开发
    Flutter防止布局溢出
    Flutter获取远程数据 刷新UI界面
    Flutter日常笔记
    POJ 3299 Humidex
    POJ 1207 The 3n + 1 problem
    POJ 1005 I Think I Need a Houseboat
    POJ 1004 Financial Management
    POJ1012
  • 原文地址:https://www.cnblogs.com/luomsg/p/6425177.html
Copyright © 2011-2022 走看看