spring 读取account-service中的值

account-service

//main--resources--account-service.properties 文件位置

email.protocol=smtps
email.host=smtp.163.com
email.port=465
email.username=atzhang3si@163.com
email.password=TKOBSJJCSHTKHRCQ
email.auth=true
email.systemEmail=675742869@qq.com
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>

  

posted @ 2020-12-15 20:42  张艳涛&java  阅读(113)  评论(0编辑  收藏  举报