spring读取配置文件的两种方式

来源:互联网 发布:怎么免费做网络推广 编辑:程序博客网 时间:2024/05/19 20:45

方式一:
bean注入方式:

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">      <property name="locations"> <!-- PropertyPlaceholderConfigurer类中有个locations属性,接收的是一个数组,即我们可以在下面配好多个properties文件 -->          <array>              <value>classpath:jdbc.properties</value>          </array>      </property>  </bean> 

方式二:
注解方式:

<context:property-placeholder location="classpath:conn.properties"/><!-- 加载配置文件 --> 
原创粉丝点击