Environment-specific configuration in a maven-spring-mvc project
For once, this article is not about a conference but about some issues I thought about recently.
The context is a training session I give in my company. In that training session, I use a web app to illustrate some points and let the attendees perform some exercises. The web app project uses maven, spring-mvc and multiple databases (mysql and hsqldb) for different purposes (local playing, local integration tests, CI integration tests and “production”).
Those different purposes have different needs. Ideally, I would like to have something like:
- local playing –> local mysql database
- local integration tests –> hsqldb in-memory database
- CI integration tests –> dedicated mysql database running on the CI server
- “production” –> dedicated mysql database running on the “production” server
To update schema updates, I use liquibase. I would like to run it in update mode on environments 1, 2 and 4 and in drop-and-create mode on environment 3.
I know a lot of different solutions that can achieve this situation, but the solution must be neat (it’s a beginner training application and thus shouldn’t attract the focus on themes I don’t want to talk about). Currently, I still haven’t found THE perfect solution. So I’ll describe the ones I’ve already tried with some kind of success in coming articles. Feel free to propose anything in comment. I’ll be glad to investigate your propositions.