spring讀取配置文件的兩種方式

方式一:
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"/><!-- 加載配置文件 --> 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章