21 November, 2013

Spring-Boot's auto-configurer seems good for simple applications.
For example it automatically creates DataSource and JdbcTemplate, when you need to connect to the database. But what about less trivial configuration, when you have several different databases?

I found the way to have multiple DataSources for Spring-Boot-based application.

In the sample below I have two special (db-related) Configurations, one properties file with connections' parameters and two Repositories.

Each @Repository connects with appropriate database through separate DataSource.

Spring's guys are doing new revolutionary thing - spring-boot
With spring-boot creation of standalone application has become much easier and faster.
Auto-configurations, embedded servlet-containers, all-in-one jar - sometimes it looks like magic.
It seems OK for starters and prototypes, but what about production and hi-load applications...