1

I have many property sets defined in spring.xml created by factory bean. I'm looking for spring solution to merge them into single bean. So:

INPUT: 2 or more beans of type java.util.Properties

OUTPUT: single bean of type java.util.Properties

Is there something like that in Spring or as free available code? I don't want to reinvent the wheel :)

4

1 回答 1

1

You can merge java.util.Properties beans using the putAll method.

@Resource Properties properties1
@Resource Properties properties2

@Bean
Properties mergedProperties(){
    Properties mergedProperties = new Properties();
    mergedProperties.putAll(properties1);
    mergedProperties.putAll(properties2);
    return mergedProperties;
}

See also: How to merge two java.util.Properties objects?

于 2013-02-08T16:37:10.670 回答