1. 程式人生 > 實用技巧 >spring 讀取account-service中的值

spring 讀取account-service中的值

account-service

//main--resources--account-service.properties 檔案位置

email.protocol=smtps
email.host=smtp.163.com
email.port=465
[email protected]
email.password=TKOBSJJCSHTKHRCQ
email.auth=true
[email protected]
persist.file=${project.build.testOutputDirectory}/persist-data.xml

 何處引用

 

//account-persist工程下的src-main-resources-account-persist.xml

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

	<bean id="propertyConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location" value="classpath:account-service.properties" />
	</bean>

	<bean id="accountPersistService"
		class="com.juvenxu.mvnbook.account.persist.AccountPersistServiceImpl">
		<property name="file" value="${persist.file}" />
	</bean>

</beans>