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 :)

1 Answer 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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.