Scaffolding a Spring MVC Application

This tutorial walks you through producing a ready-to-run Spring MVC customer application that implements the CRUD application pattern for a domain model.  In this tutorial you will learn how to:

  • Scaffold from a database table into an existing project
  • Deploy a scaffolded application

Scaffolding with Spring MVC requires a MyEclipse Spring or Bling subscription.

1. Create a Web Project

Create a MyEclipse Web project named CustomersApp.

Note: If you get a popup regarding the project compiler compliance level not matching the workspace default, specify that you want to use a custom setting for the project by clicking Yes.

New web project

2. Scaffold from a Database Table

Scaffolding generates software components and configuration files required to implement the CRUD application.

Note: If you want to use the Spring DSL, then you need enable the project for Spring DSL support prior to scaffolding. See Enable Spring DSL for more information.

  1. Right-click CustomersApp, and select Spring Tools>Scaffold Spring CRUD Application This menu option was updated in MyEclipse 2017. For prior versions, click here. .
  2. Select the Database Schema option, which will scaffold from an existing database table in the MyEclipse Derby database. Click Next.

    Selecting artifact types to use for scaffolding
  3. Select the MyEclipse Derby connection from the list of configured DB connections, and click Next.

    Selecting the DB connection
  4. Select the CLASSICCARS schema, add the CUSTOMER table to the scaffolding list, and click Next.

    Selecting the database table to use for scaffolding
  5. Accept the selected Java object as the parent object, and click Next.

    This page also lets you override the derived name of the Java object created from the database table. Java object names are derived automatically from table names, but the name can be overridden by double-clicking the name and typing a new name.

    Database scaffolding options
  6. Specify the layers of the application to scaffold and the package names for each layer. All layers are enabled by default. Type org.customerapp as the base package. The package names for the layers are derived automatically from the base package. A sub-package (i.e., web, service, DAO, and domain) is added to the end of the base package. Click Next.

    Application layers and packages
  7. Select the Generate checkbox for Spring MVC to indicate which clients should be generated for the web layer, and click Next.

    Selecting the Spring MVC web client
  8. Accept the default project configuration options, and click Next.

    Configuration options
  9. Accept the default Spring Capabilities settings, and click Next.

    Adding Spring capabilities
  10. Accept the default REST options, and click Next.
    Accepting REST options default
  11. Accept the defaults on the Customize UI page, and click Next.

    Note: The field names are derived automatically from the column names of the selected database tables, but the field name can be overridden by double-clicking the name and typing a new name.

    UI customization options
  12. Accept the default locations for generated files (source code, configuration files, JSP, etc…), and click Next.

    Selecting target folders
  13. Accept the default runtime libraries and options, and click Next.

    Runtime dependencies
  14. Click Finish on the summary page.

    Summary page

3. Deploy the App

The next step is to see the application in operation by deploying it to Tomcat. The running application can be used for validating the generated Spring MVC components and observing the integration with the other components of the application.

  1. Right-click CustomersApp, and select Run As>MyEclipse Server Application.
  2. Select the MyEclipse Tomcat application server and click Finish.

    Deploying the application

    MyEclipse Tomcat opens the application. The first page is a dashboard for accessing all scaffolded web clients. Because this tutorial only scaffolded a single database table for Spring MVC, the only option under Spring MVC is View Customers.
  3. Click the View Customers button to see the generated application in operation. If you want to run the application in a separate browser, use the following URL: http://localhost:8080/CustomersApp/.


The Spring MVC application can be used to list all customers, view customer details, edit customer details, delete customers and add new customers.

Customer app list

Customer app edit details

4. What’s Generated?

To ease your way into code generation, this tutorial involved scaffolding from only a single database table. Therefore, only the software components for managing a single entity were generated, and there were no entity relationships. When you start generating for multiple entities, potentially with entity relationships, there are many more software components generated than were generated with this tutorial. Even though there’s a lot more code, it is grouped and organized as shown in the following images.

Generated scaffolding