spring properties

Edit

[시대 착오적인 설정 파일 *.properties를 버리자](http://kwon37xi.egloos.com/4665590) 참조

스프링에서는 <context:property-placeholder/>, <util:properties/>, 국제화 메시지용 Resource Bundle에서 모두 'Properites XML’형식을 지원합니다. 3.1에서는 <context:property-placeholder/>와 @PropertySource를 썼을 때 'Properties XML' 형식이 인식이 안 되는 버그가 있었습니다. 3.1.2에서 이를 회피하는 방법은 <http://wiki.kwonnam.pe.kr/springframework/propertysource>를 참조하시기 바랍니다. 3.1.4, 3,2.1에서는 이 Bug가 fix되었습니다. 스프링의 이슈트랙커에 아래와 같이 등록되어 있습니다.

filesystem과 classpath에서 동시에찾는 설정

<context:property-placeholder location="file:config.properties, classpath:config.properties" ignore-resource-not-found="true"/>

Spel

@Value("#{server.hostName}")

<bean id="server" class="java.net.InetAddress" factory-method="getLocalHost"/>

<bean id="persistentMessageStore"  class="org.springframework.integration.jdbc.JdbcMessageStore">
    <property name="tablePrefix" value="channel_" />
    <property name="region" value="#{server.name}" />
    <constructor-arg ref="masterDataSource" />
</bean>

PropertyEditor

<bean id="dateEditor"  class="org.springframework.beans.propertyeditors.CustomDateEditor">
    <constructor-arg>
      <bean class="java.text.SimpleDateFormat">
        <constructor-arg value="yyyy-MM-dd HH:mm:ss" />
      </bean>
    </constructor-arg>
    <constructor-arg value="true" />
</bean>

<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
    <property name="customEditors">
      <map>
        <entry key="java.util.Date">
          <ref local="dateEditor" />
        </entry>

      </map>
    </property>
</bean>