Chapter 2. Generate a project using SpringFuse

2.1. Extract your database-schema

In this section we explain how to run 'maven-springfuse-plugin', a Maven 2 plugin provided by SpringFuse in order to extract your database schema from your database. The plugin runs locally on your machine.

[Important]Important
Even if the plugin does not read your data or write anything in your database, we highly recommend you to use a database dedicated to development, ideally a database running on your computer.

Download and save the following pom.xml on your computer in an empty directory. For those new to Maven, the pom.xml is the equivalent of build.xml for Ant.

Open the pom.xml in a text editor and edit the following properties so the plugin can access your database:

<database.name>minimal</database.name>
<database.host>localhost</database.host>
<database.user>minimal</database.user>
<database.password>minimal</database.password>

Once set open a console and from the directory containing the pom.xml file. We assume here that you use the postgresql profile. If not, please refer to the pom.xml which has other profile defined. Run Maven as follow:

> mvn -Ppostgresql

[Note]Note
If you use Maven for the first time or this plugin for the first time, Maven will automatically download some required dependencies. It may take several minutes, so just be patient!

Overall, you should end up with a result that looks like this

>mvn -Ppostgresql
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'springfuse'.
[INFO] ------------------------------------------------------------------------
[INFO] Building minimal
[INFO]    task-segment: [springfuse:extract]
[INFO] ------------------------------------------------------------------------
[INFO] [Springfuse:extract]
[INFO] Ready to extract the database schema
[INFO] Connecting to Database jdbcUrl=jdbc:postgresql:minimal
[INFO] Connected OK
[INFO] Database Product Name: PostgreSQL
[INFO] Database schema extracted
[INFO] File data-model.springfuse created successfully
[INFO] You are now ready to upload data-model.springfuse to http://www.springfuse.com/ and generate your project!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Wed Nov 26 18:10:21 CET 2008
[INFO] Final Memory: 2M/6M
[INFO] ------------------------------------------------------------------------

If all went successfully, you should find the file data-model.springfuse under the same folder. If not, please refer to the troubleshooting section. The data-model.springfuse file contains only meta data information. It does not contain any database data or your jdbc login/password.

2.2. Upload your data-model and generate your project

Generating a project is now simple. You just have to upload the data-model.springfuse file and provide a project name and the java package that will be used as a root package for the generated Java code. The generation process may take from 4 to 30 seconds.

[Tip]Simplify your configuration effort!

If your database name, jdbc login and password are all equals. Then choosing a project name that matches this single value will allow you to run the generated project out-of-the-box, without any configuration modification!