Here is a snippet, first setup some stuff in code, then load an xml.
Code:
Map dataSourceProperties = new HashMap();
dataSourceProperties.put("dataSource.class",
"org.apache.commons.dbcp.BasicDataSource");
dataSourceProperties.put("dataSource.driverClassName", databaseProperties
.getDriverName());
dataSourceProperties.put("dataSource.url", databaseProperties.getUrl());
dataSourceProperties.put("dataSource.username", databaseProperties.getUsername());
dataSourceProperties.put("dataSource.password", databaseProperties.getPassword());
GenericApplicationContext applicationContext = new GenericApplicationContext();
// Load from properties
PropertiesBeanDefinitionReader propReader = new PropertiesBeanDefinitionReader(
applicationContext);
propReader.registerBeanDefinitions(dataSourceProperties);
// Next load other beans
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(applicationContext);
xmlReader.loadBeanDefinitions(new ClassPathResource("spring-beans.xml"));
applicationContext.refresh();