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



pom.xml

web.xml

spring-servlet.xml

Employee.jsp

ListEmployees.jsp

mybatis-config.xml

MyBatisUtil.java

Employee.java

EmployeeMapper.xml

EmployeeMapper.java

EmployeeController.java

index.jsp

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.

About the author

Bushan Sirgur

Well, I am Bushan Sirgur from Banglore, India. Currently, I am working as a Software Developer in a Service Base Company. I am interested in JAVA/J2EE, Angular 2, JavaScript, jQuery, MongoDB.

View all posts

20 Comments

Leave a Reply

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