A Complete CRUD Application with Spring MVC and MyBatis/iBatis

Welcome back, Developing a Web Application in Java/J2EE is really really good, there are so many frameworks available out there. So today, in this article, let’s discuss one of the popular Java framework, Spring MVC and MyBatis/iBatis, using these two frameworks let’s create complete CRUD application

MyBatis is a Java persistence framework that couples objects with stored procedures or SQL statements using an XML descriptor or annotations. MyBatis is free software that is distributed under the Apache License 2.0. MyBatis is a fork of iBATIS 3.0 and is maintained by a team that includes the original creators of iBATIS.

The Spring Framework is an application framework and inversion of control container for the Java platform. The framework’s core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE (Enterprise Edition) platform. Although the framework does not impose any specific programming model, it has become popular in the Java community as an addition to, or even replacement for the Enterprise JavaBeans (EJB) model. The Spring Framework is open source.

Steps to be followed:

Step 1: Create a maven project

Step 2: Configure web.xml and spring-servlet.xml file

Step 3: Add required dependencies to pom.xml

Step 4: Create 4 packages, Controller, DAO, Entity, and Util

Step 5: Create 1 Resources folder, add the mybatis-config.xml file to it. Inside that file specify JDBC properties

Step 6: Create a folder named jsps inside the WEB-INF

Let’s design the DB first,

NOTE: I am using MySQL DB throughout this article, you can use any other DB.

Execute the below command to create DB,

Execute the below command to use DB,

Let’s design our employee table,

Next step is to create a maven project in eclipse













So now let’s run the application, and you will see this landing page,

Love this post?

Help me to buy a cup of coffee/Support us by donating.
All the donations will be going to the website maintenance/improvement.

Pay Now


That’s it for this article, I hope this article helped you in one or the other way, do let me know about this article, if you like the content, do share this article with your friends, I will see you in the next article.

21 thoughts on “A Complete CRUD Application with Spring MVC and MyBatis/iBatis”

  1. I needed to leave a comment, man do I have a hard time writing
    a blog. Im wanting to kick start one on my website and I have to say
    its challenging at all. I do admire people like yourself who are

    able to reveal anything easily. Keep up the nice work!

  2. Mу brother suggеsted I might like thiѕ blog. He was
    entirely right. This post actᥙally mɑde my day. You cann’t imagine just һow much
    time I had spent for this info! Thanks!

  3. I just lіke the valuabⅼe information you supply on your articles.
    I will bookmark your bloɡ and test once more
    right here regularly. Ι’m moderately sure I will
    be told many new stuff гight right here! Good
    luck fоr thе next!

  4. Gracias por el ejemplo. Ya lo puse a funcionar. Me dio mucho trabajo encontrar las versiones de los JAR. Los puede encontrar Exactos en otro ejemplo de CRUD que estaba rodando por InterNet crud-spring-mvc-mybatis-master.zip .

          1. You’re welcome 🙂 If this post is helped you then please share this post in all your social media profiles and help your friends and collegues to find this post 🙂

  5. Hi Bushan,
    Good tutorial thanks… I am working on a project where ibatis 2 with spring 3 is used. I want to migrate to spring 5 which does not support ibatis so moved to mybatis v3.5 and so migrated abator files (mybatis .xml config files) as per mybatis migration guide [http://mybatis.org/generator/migratingFromAbator.html]
    Now using mybatis generator I need to create DAO/impl and Domain classes but somehow they extends SqlMapClientDaoSupport which was deprecated in spring 4 itself so no library in spring 5 supports this.
    My question is what changes should be applied to mybatis config xml file so that mybatis generator creates DAOImpl classes does not extend the deprecated class. One more thing I have lots of such xml file for lots of table that already exists and I cannot loose data.
    Thanks in advance…!

  6. Aw, this was an exceptionally good post. Taking the time and actual effort to generate
    a top notch article? but what can I say? I procrastinate a lot and never seem to get anything done.

Leave a Reply

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