1. 程式人生 > >Spring讀取property檔案的兩種配置:EL表示式和placeholder表示式

Spring讀取property檔案的兩種配置:EL表示式和placeholder表示式

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">


	<!-- --------------------------properties file---------------------------------- -->
	<!-- resource list -->
	<bean id="resourceList" class="java.util.ArrayList">
		<constructor-arg>
			<list>
				<value>classpath:application-test.properties</value>
				<value>classpath:application-test1.properties</value>
				<value>classpath:application-test2.properties</value>
				<value>classpath:application-test3.properties</value>
			</list>
		</constructor-arg>
	</bean>

	<!-- support expression language -->
	<!-- <util:properties id="testProperties" location="classpath:bootstrap-test.properties" /> -->
	<bean id="configProperties"
		class="org.springframework.beans.factory.config.PropertiesFactoryBean">
		<property name="locations" ref="resourceList">
		</property>
	</bean>

	<!-- support placeholder -->
	<bean id="propertyPlaceholderConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="ignoreUnresolvablePlaceholders" value="true" />
		<!-- <property name="locations" ref="resourceList" /> -->
		<property name="properties" ref="configProperties" />
	</bean>

	<!----------------- bean annotation driven -------------------------------- -->
	<context:annotation-config />
	<context:component-scan
		base-package="com.xxx.test" />

	<!-- ------------------import local src/main/resources/ ------------------------- -->
	<import resource="classpath:/config/xxx.beans.xml" />

</beans>

相關推薦

Spring讀取property檔案配置EL表示式placeholder表示式

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/

spring 讀取properties的方法

jdbc factor frame ram con framework html tex 讀取 一:直接使用context命名空間 如: <beans xmlns="http://www.springframework.org/schema/beans" xm

spring定時器的配置方式

 1、加入依賴包: <dependency> <groupId>org.quartz-scheduler</groupId> <artifact

使用Spring讀取xml檔案中的配置資訊

一般寫程式時我們都會將一些配置資訊寫到配置檔案中,以便在不修改原始碼的情況下對程式的某些點進行更改。這裡介紹一種Spring讀取xml配置檔案的方式,其基本思路如下:定義一個java類,其中定義一些靜態變數對應我們的配置資訊,然後採用注入的方式將變數值初始化為配置值。示例程

PPP的配置方法(papchap)

pap chapPAP的配置R1上的配置[R1]int s4/0/0[R1-Serial4/0/0]ppp authentication-mode pap[R1-Serial4/0/0]q[R1]aaa[R1-aaa]local-user huawei password cipher 123456Info:

自制按鈕圖標的方法 image spritesvg字體文件

輸出 圖標 int uil pac 設置 定制 方法 ets 用image sprite和svg字體文件這兩種方法,都能夠極大地減少小圖形文件的數量, 從而減少服務器請求和帶寬需求。提高網頁的響應速度。 一、建立SVG字體文件 iconmoon 是一個在線工具,可以上傳

Vue-詳解設定路由導航的方法router-linkrouter.push

轉自:http://www.cnblogs.com/superlizhao/p/8527317.html 一、<router-link :to="...">  to裡的值可以是一個字串路徑,或者一個描述地址的物件。例如: // 字串 <router

css實現tooltips框的三角角標 方法偽類C3旋轉

一、皆為邊框 第一種 Css的border取其一為三角 第二種 C3新屬性 旋轉(transform:rotate(45deg);) 二、皆為陰影(採用C3旋轉) 完整程式碼 整個複製

H264碼流的形式Annex BAVCC——非常詳細的翻譯

本文需要讀者對H.264流有一定的瞭解才可以理解2種格式差異。          首先要理解的是沒有標準的H.264基本流格式。文件中的確包含了一個Annex,特別是描述了一種可能的格式Annex B格式,但是這個並不是一個必須要求的格式。標準文件中指定了視訊怎樣編碼成獨立的包,但是這些包是怎樣儲存和傳輸的

配置Servlet的IP地址對映1註解、2配置檔案

1.建立專案 建立 servlet_test 動態web專案。 建立時點選 next, 勾選如下: 2.建立 test.java類 test.java 內容: 第一種:註解 – 設定IP地址對映

SpringBoot的propertiesyml配置方式, 配置注入引數, 以及配置檔案讀取失效的問題

SpringBoot支援兩種配置方式,一種是properties檔案,一種是yml 首先在pom檔案中新增依賴: <dependency> <groupId>org.springframework.boot</gro

springBoot使用Controller讀取配置檔案方式&讀取自定義配置方法

Controller 核心配置檔案 application.propertie web.msg=Hello! This is Controller demo; Controller:

spring 配置方式JAVA配置註解配置

眾所周知,spring自從3.0開始以後,就全面推薦使用配置的方式進行程式碼編寫了,這種方式確實可以避免了之前一個專案裡面一大堆XML的情況,畢竟XML的可讀性實在不怎麼樣,而且一會寫JAVA,一會寫XML,確實還是蠻麻煩的 就目前來說spring的配置方式一

MFC操作XML配置檔案方式DOM MSXML

這幾天做VC專案涉及到了建立xml配置檔案這方面的問題,糾結了好多天,嘗試了N種方法,終於完成了工作任務,現在和大家分享下:  我參考瞭如下的資料: XML DOM 例項:http://www.w3school.com.cn/example/xdom_examples.as

Spring boot配置檔案方式

[email protected](prefix = “author”) application.properties author.name=liuyuzhu author.age=31 2 @ConfigurationPropertie

Spring Cloud Gateway+Nacos,yml+properties配置檔案方式搭建閘道器服務

寫在前面 閘道器的作用不在此贅述,舉個最常用的例子,我們搭建了微服務,前端呼叫各服務介面時,由於各服務介面不一樣,如果讓前端同事分別呼叫,前端同事會瘋的。而閘道器就可以解決這個問題,閘道器遮蔽了各業務服務的埠,對前端同事來說,他們只負責呼叫閘道器服務埠下的服務就可以了。本文簡單描述如何使用Spring Clo

java框架篇---spring aop配置方式

system 操作類 asp xml文件 ack ica one pack exc 第一種:註解配置AOP 註解配置AOP(使用 AspectJ 類庫實現的),大致分為三步: 1. 使用註解@Aspect來定義一個切面,在切面中定義切入點(@Pointcut),通知類型(@

spring AOP的配置方式

can 之前 top () 就是 記錄 string -s 服務   連接點(JoinPoint) ,就是spring允許你是通知(Advice)的地方,那可就真多了,基本每個方法的前、後(兩者都有也行),或拋出異常是時都可以是連接點,spring只支持方法連接點。其

第四節框架前期準備篇之進程外Session的配置方式

connect 也會 strong 缺點 col 客戶端 配置 ott 小學生 一. 基本介紹 1. 背景:Asp.Net默認的Session機制是進程內,存儲在服務器端內存中,有這麽幾個缺點:   ①:既然存在內存中,空間有限,不能存儲大數據量信息,數據量多的話S

淺談Spring配置容器

簡單的 url 上下 rip 快的 png getbean 比較 file 淺談Spring的兩種配置容器 原文:https://www.jb51.net/article/126295.htm 更新時間:2017年10月20日 08:44:41 作者:黃小魚Z