Skip to content

Instantly share code, notes, and snippets.

@peter-y
Last active September 28, 2021 06:39
Show Gist options
  • Save peter-y/852f1d42da931c9b5b5c60bd04fe3741 to your computer and use it in GitHub Desktop.
Save peter-y/852f1d42da931c9b5b5c60bd04fe3741 to your computer and use it in GitHub Desktop.
PropertyPlaceholderConfigurer 配置 加载 properties 文件
<!-- 写法1 -->
<bean id="mappings"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<!-- typed as a java.util.Properties -->
<property name="properties">
<value>
jdbc.driver.className=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mydb
</value>
</property>
<property name="location">
<value>
/*.properties
</value>
</property>
</bean>
<!-- 写法二 -->
<context:property-placeholder location="classpath:*.properties"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment