Showing posts from May, 2018

Advanced wiring in Spring

Many times we face situation in which we want certain things configured as per the environment or on certain complex condition. Spring provides great features in easing the developer job for this use-case. We will look at such a scenario along with solution spring provides in this case. Environments and Profiles: One of the most challenging part of any application is to transitioning of the software into different environments (DEV, QA, STG, PROD). Certain choices that we make in DEV environments are not suitable when we run the same setup on PROD environment. Consider basic use of using different database as per the deployment environment. for DEV we might setup a datasource something like below: @Bean(destroyMethod = "shutdown") public DataSource dataSource() { return new EmbeddedDatabaseBuilder() .addScript("classpath:devCreate.sql") .addScript("classpath:devInsert.sql") .build(); } but when we will go on PROD environment, this c