Spring的配置文件中使用属性文件

加入context命名空间

xmlns:context="http://www.springframework.org/schema/context"

和xsi:schemaLocation中加上

http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd

然后使用

<context:property-placeholder location="classpath:jdbc.properties"/>导入属性文件

可以使用${属性key}

如:

<property name="username" value="${username}"/>



原文地址:https://www.cnblogs.com/tazi/p/2304375.html