Automate Spring MVC Project


There are times, when you want to try out small things, but which requires a full fledged development environment, without the overwhelming details of the project. You just want the minimal project where you can try out small examples, before you can integrate it in the main project. The danger of even using a copy of a big project to try out small things, can sometimes be very complex. You can easily get off track and be confused on where did you made the changes (don’t count svn diff on this).

It is thus good to automate the basic environment, so that you can keep on adding things in parts. I believe you can create complex software out of simple parts, but you cannot build even a usable software with complex blocks. If you have such grip over your project (i.e you can retrace and recreate the same environment, without getting lost on how did you get there) you can tryout all sorts of ideas to create amazing parts to the software. I myself have been in so many situations where I could not complete even a simple logic for a whole day, because I got lost many times on where I should add those codes. Such uncertainty happens often in web projects (css, javascript, ajax). Sometimes we need to talk with the database, it is lot of unnecessary work to create similar situation in jdbc, if you have already written the project in spring, hibernate.


Start creating a basic project that has everything that a working environment needs. E.g if you are working on spring, hibernate you should try to automate most of the things, so that you can create as many copies of such project as you want. Some might argue, why not create a basic project and use that copy to do things. That is a second solution. The best solution is always where  you should not have to write a single word to change the basics.

I often try to use scripting languages to automate such things. Not only using languages appropriate for certain jobs helps you learn such new languages, it also opens a new world, new prospective where you can think of a problem in two different ways (your native language and the scripting language). You don’t have to take a book and start learning the new language. I was able to create such an environment with just half an hour of careful learning of necessary commands. If you are going to use Linux to do so, bash could be a perfect choice. You need to know syntax for creating and reading files, you need to know how to write basic controls, loops etc. As you go, you will need certain task specific commands, which you can find with a little help on the internet.

This is a simple project, that helps to create a simple project with the help of a simple config file. If you don’t change the config file, a default project will be created.


I often had to work on projects that required database connection (specially mysql), would be in spring mvc, would have hibernate as the persistent manager and a service layer to ease things a bit. I would use maven 2 to deploy the application, so that I would not have to wonder for jars everywhere.


To automate such things you have to know certain linux commands. One would be to know how to create a database in mysql from command line.

mysql -u<username> -p<password> -e "run mysql commands"

If I pass “create database <project_database>;” as the command, then I would have a perfect database ready to be used. Other than this, all the tables would be created by hibernate (“”). There will be lots of variables like project name, package name, even code style that one would want to have when creating projects. For that, I choose to create a two layers of automation. At the top level would be a script that would search a file (defined in top level configuration) that matches the directory of the default project named at top level. This gives us freedom to create versions of our own project, we just have to make sure we follow the specification of having a file that would be called from root.

The beauty of having a final config file in the directory where you want to create your project is, you can override every variables defined in parent level. Even the one defined in the root config file.

In “spring-mvc” project a file called would be called. If you have a version of config file that is inside modules/<default-template-name> directory E.g spring-mvc/modules/hibernate-mysql-version1/spring.cfg in your current directory you can change values to even variables defined in global-spring.cfg.

All the values and variables in spring.cfg are very intutive and simple to change. Only one requirement is that you have to know spring mvc project.  Please download the project at and see for yourself. Since it is an open source project, change is always welcome. My intention with the project is not to create a project that solves everyones’s problem, but to show one way to do so. Once you go through the bash scripts, I am sure you will find no difficulty in creating your own version.

Good Luck !!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s