This works for me (with your configuration from the poc archive you posted):
But maybe it should be easier. Remind me: why do you need to do the override programmatically?Code:GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(new ClassPathResource(SPRING_CONTEXT_PATH)); PropertyOverrideConfigurer cfg = new PropertyOverrideConfigurer(); cfg.setLocation(new ClassPathResource(ClassUtils.addResourcePathToPackagePath(OverridePropertiesPocTests.class, "dev/overridePropertiesPoc.properties"))); cfg.setOrder(2); context.getBeanFactory().registerSingleton("override", cfg); context.refresh(); PocBean pocBean = (PocBean) context.getBean(BEAN_ID, PocBean.class); assertEquals("value from dev properties", pocBean.getName());


Reply With Quote