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

  • 相关阅读:
    记录nginx 搭建集群环境踏过的坑
    工作中常见问题
    自定义WebViewPage,实现Url.Action生成绝对地址
    上传阿里云样式文件不解析问题一例总结
    EF4.4 升级EF6.0问题总结
    记一次数据库迁移遇到问题
    javascript 中 !~ 什么意思
    jquery.mobile 中 collapsible-set collapsible listview 共同布局问题
    T-sql脚本规范
    EasyUI使用技巧总结
  • 原文地址:https://www.cnblogs.com/luomsg/p/6425177.html
Copyright © 2011-2022 走看看