[Java] Spring Roo – webapp in 5 minutes!

Simple web application created and deployed in 5 minutes? Now it’s possible with Spring Roo – SpringSource rapid application development framework.
An example:
you wants to create application that keeps data of your clients and you don’t need nothing more. What to do?
1. Download Spring Roo from http://www.springsource.org/roo/ .
2. Create new dir:

mkdir example
cd example

3. Use spring-roo-x.x.x/bin/roo.sh (assume you have symbolic link in /usr/bin):


4. Type what you need:

roo> project --topLevelPackage com.codesmuggler.example
roo> persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
roo> entity --class ~.domain.Client
roo> field string --fieldName firstName --class ~.domain.Client
roo> field string --fieldName lastName
roo> field string --fieldName address
roo> field string --fieldName telephone
roo> field number --type int --fieldName priority
roo> controller all --package ~.web
roo> exit

This will create base web application which use Hypersonic database with Hibernate as ORM and your domain model: Client with base fields.
5. That’s all! Now just run your application with:

mvn tomcat:run

And see how magic happens:
Adding new Client:

Listing clients:

With Spring Roo we can create simple web applications very rapidly. Use it when you have no time and you need generic solution. Spring Roo has more possibilities, I will show some of them in the future.

This entry was posted in coding, enterprise edition, java, snippets and tagged , , , , , , spring roo, . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *



You may use these HTML tags and attributes: