I want to create datasource bean programmatically depending on args passed from user then
public class Main {
public static void main( String[] args ) throws IOException, InterruptedException {
//TODO load proper configs depending on args
//TODO initiate dataSource bean with UN and PS in args
ApplicationContext context = new ClassPathXmlApplicationContext( "config/applicationContext-common.xml" );
}
}
I’ve done a little googling already and found that I have to create a post processor bean that creates a data source bean and programmatically configures it using the fetched data.
What I’d like to see is a real example.
You can try the code below, it should inject dataSource before wiring.