zoukankan      html  css  js  c++  java
  • spring 读取properties的两种方法

    一:直接使用context命名空间

    如:

    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:websocket="http://www.springframework.org/schema/websocket"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    	   http://www.springframework.org/schema/beans/spring-beans.xsd
    	   http://www.springframework.org/schema/websocket
           http://www.springframework.org/schema/websocket/spring-websocket.xsd
    	   http://www.springframework.org/schema/context 
    	   http://www.springframework.org/schema/context/spring-context.xsd">



    <context:property-placeholder location="classpath:log4j.properties" />

    二:在配置文件里配置PropertyPlaceholderConfigurer

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    	<property name="locations" value="classpath:jdbc.properties" />
    </bean>

    然后在须要的地方直接下面方式引用

    <property name="url" value="${jdbc.url}"/>


  • 相关阅读:
    Linux网络编程--socket
    UDP学习总结
    TCP协议学习总结
    DNS协议总结
    DHCP协议总结
    ARP协议总结
    二层协议--MPLS协议总结
    二层协议--LLDP协议总结
    二层协议--LACP协议总结
    二层协议--STP协议总结
  • 原文地址:https://www.cnblogs.com/lxjshuju/p/6876589.html
Copyright © 2011-2022 走看看