Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

overwrite confguration value spring

public class PropertyOverrideContextInitializer
  implements ApplicationContextInitializer<ConfigurableApplicationContext> {

    static final String PROPERTY_FIRST_VALUE = "contextClass";

    @Override
    public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
        TestPropertySourceUtils.addInlinedPropertiesToEnvironment(
          configurableApplicationContext, "example.firstProperty=" + PROPERTY_FIRST_VALUE);

        TestPropertySourceUtils.addPropertiesFilesToEnvironment(
          configurableApplicationContext, "context-override-application.properties");
    }
}
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #overwrite #confguration #spring
ADD COMMENT
Topic
Name
1+3 =