简体   繁体   中英

migrating from XML to annotations (spring)

I´m trying to migrate form XML to annotations this code:

<bean       
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="ignoreResourceNotFound" value="true" />
  <property name="locations">
     <list>
       <value>classpath:spring/file1.properties</value>
       <value>file:${file.prop}</value>
     </list>
   </property>
</bean>

I don´t know how to migrate the locations lists, I have to create a array of Resources (Resource[]), but how can I migrate each value?

@Bean
public PropertiesFactoryBean fieldNamesProperties() {
   PropertiesFactoryBean fieldNamesProperties = new PropertiesFactoryBean();
   fieldNamesProperties.setIgnoreResourceNotFound(true);
   Resource[] locations = new Resource[2];
   // TODO add resources

   fieldNamesProperties.setLocations(locations);
   return fieldNamesProperties;
}
PropertiesFactoryBean fieldNamesProperties = new PropertiesFactoryBean();
fieldNamesProperties.setLocation(new ClassPathResource("/spring/file1.properties"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM