freelymen

1.Spring中通过@Value注解注入属性的方式
<!-- 方式一、PropertyPlaceholderConfigurer,访问方式@Value("${tag}") -->
<bean id="appProperty"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:app.properties"/>
</bean>
<!-- 方式二、PreferencesPlaceholderConfigurer,访问方式@Value("${tag}") -->
<bean id="appProperty2"
class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
<property name="location" value="classpath:app2.properties" />
</bean>
<!-- 方式三、PropertiesFactoryBean,访问方式@Value("#{appProperty3['tag']}") -->
<bean id="appProperty3" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="classpath:app3.properties" />
</bean>
<!-- 方式四、util:properties,同PropertiesFactoryBean,访问方式@Value("#{appProperty4['tag']}") -->
<util:properties id="appProperty4" location="classpath:app4.properties"></util:properties>

相关文章:

  • 2021-09-29
  • 2018-03-13
  • 2021-08-08
  • 2021-07-01
  • 2021-05-11
  • 2021-09-10
  • 2021-07-23
猜你喜欢
  • 2021-08-31
  • 2021-12-08
  • 2021-10-04
  • 2021-11-13
  • 2021-09-10
  • 2021-06-10
  • 2022-01-05
相关资源
相似解决方案