spring
spring
Submitted By
RAJESH CHANDRA SAHU
(234420100033)
CERTIFICATE
DECLARATION
(Signature of Student)
CENTURION UNIVERSITY OF TECHNOLOGY AND MANAGEMENT
ACKNOWLEDGEMENT
The satisfaction and euphoria that accompany a successful completion of any
task would be incomplete without the mention of people who made it possible,
success is the epitome of hard work and perseverance, but steadfast of all is
encouraging guidance. So, it is with gratitude that we acknowledge all those
whose guidance and encouragement served as beacon of light and crowned our
effort with success. We would like to thank JYOTI PRAKASH DAS , Principal of
CUTM, chatrapur, for providing an excellent academic environment in the
college and his never-ending support for the MASTER IN COMPUTER
APPLICATION program. We consider it a privilege and honour to express our
sincere gratitude to our internal guide DEEPAK KUMAR BEHERA(Lecture in
MCA) , School of Applied Science (MCA) for their valuable guidance throughout
the tenure of this project work. We would also like to thank all the faculty
members who have always been very Co- operative and generous. Conclusively,
we also thank all the non-teaching staff and all others who have done immense
help directly or indirectly during our project.
iv
TABLE OF CONTENT
SL NO INDEX PAGE NO
1 Introduction 7
2 E-Commerce Web 9
Application
3 Function Components 11
6 Layer 18
7 Conclusion 20
8 Reference 21
v
ABSTRACT
E-Commerce is the most preferred and efficient way of trading services and goods. Today, more
and more customers prefer to buy articles through the internet and it has helped many small
businesses establish a wider market presence by providing low-cost and more efficient distribution
channels for their products or services. E-commerce to change the traditional retail industry is an
unstoppable trend. In this project, I will build an e-commerce web application with the help of Spring
Boot which is the most popular java web enterprise framework. I will use Java and Spring Boot
framework to design the web server of the e-commerce application, and interact with MySQL
database with the help of MyBatis persistence framework. Through this project, I will demonstrate the
integration of Spring, Spring MVC, and MyBatis(SSM framework) in the implementation of an e-
commerce application.
Key word: Spring, Spring MVC, MyBatis, SSM
vi
INTRODUCTION
1.1 Spring Framework
The Spring Framework is an application framework and the first version was written by Rod
Johnson, who released the framework with his book “Expert One-to-One J2EE Design and
development” in October 2002. Even if the initial version of the Spring framework was released about
20 years ago, it is still one of the most popular application development frameworks used by java
developers. It currently consists of a large number of modules providing a range of services. Many
developers and techniques focus on the Spring consulting, supporting, and training. New versions are
released every year. The following figure 1 shows you the history of the Spring.
A Spring MVC is a Java framework which is used to build web App. It follows the Model-View-
Controller design pattern. It implements all the basic features of a core spring framework like
Inversion of Control, Dependency Injection.[1] As we know, “Model-” contains the data of
application, and each single data can be an object or a collection of objects. “View-” represents
information in a particular format such as JSP file or HTML file. “Controller-” contains business
logic of application and different controllers will be used for different requests. Spring MVC model
comprises six components as follows:DispatcherServlet: It receives the request that clients send and
transferred to it by Web.xml file
● Handler Mapping: Whenever Dispatcher Servlet receives incoming requests, it will map the
requests to different individual controllers with help of Handler Mapping. In Spring Boot, we use
annotation @RequestMapping instead of Handler Mapping.
● Controller: It handles the incoming requests and responses to an action that the user does.
●Model and View: After controllers handle its particular requests and the Model and View associate
with the particular request and return the name of view back to DispatcherServlet.
● View Resolver: It resolves the view based on output given by Model and View and selects the
media. [1]
● View: it is a way of representing the output to end clients.
7
Figure 2 Spring MVC working flow
Spring framework comprises many modules such as the core container, Spring context, Spring
AOP, Spring DAO, Spring ORM, Spring Web Module, Spring MVC framework as shown below in
figure 3. The most important features are the Inversion of Control (IOC), Aspect oriented
programming (AOP), and the Spring MVC design pattern. In this project, we will focus on Inversion
of Control and Spring MVC, and also introduce how to configure Spring configuration files and
JDBC, and some
other features [3].
Inversion of Control: it means that giving control of creating and instantiating the Spring beans
(objects) to the Spring IOC container and the only work that developers do is configuring the beans in
the spring.xml file. Spring IOC container is at the core of the Spring framework and container will
help developers create objects, wire objects together, configure them, manage their complete life
cycle from creation till destruction. IOC container managers one or more beans(objects) in the form
of XML. Spring.xml is a list of classes that are under the control of the Spring IOC container. As we
see in Figure 4 Spring.xml file, many beans are configured in the spring.xml file and the Spring IOC
container will manage those classes and perform actions such as creation, maintenance, destruction
throughout the whole life cycle.
8
Figure 4 Spring.xml file
Starting with Spring 2.5, the framework introduced annotations-driven Dependency Injection. The
main annotation of this feature is @Autowired. It allows Spring to resolve and inject
collaborating beans into our bean. Aspect oriented Programming: With the help of AOP the various
concerns present in a system can be separated easily. In spring aspects are joined together with the
help of spring.xml and coding is well modularized. [4]
Whenever we want to build an application like an E-commerce system, Spring framework can be
used with many other frameworks such as Spring MVC, and MyBatis. The SSM integration
framework: it is the integration of three open-sourcing frameworks, Spring MVC, Spring, MyBatis. It
is also a typical MVC framework. It divides the whole system into four layers: presentation layer
9
(JSP and related JS), control layer, service layer and database access layer. MyBatis: it is an excellent
data persistence framework. It supports custom SQL, storing procedures, and advanced mapping.
MyBatis framework has both the advantages of Hibernate and JDBC. Programmers can write SQL
statements by themselves to facilitate optimization of SQL statements, while avoiding almost all
JDBC codes and manually setting parameters and obtaining result sets [1].
The MyBatis functions can be shown in figure 6:
Spring, Spring MVC, MyBatis can be combined together to make an efficient E-commerce
application. The MyBatis framework with MVC design pattern can help in handling the data which is
present in the system and help storing and requesting the data from the database. Spring MVC
framework with Spring framework can help in handling the business logic and communication of end
users and servers. The architecture based on integration of above frameworks can be shown as below:
2.2 Back-End
The priority of data processing depends on the complexity of data, and we usually deal with the
simple data first and then work on the complexity ones. There is so much data in E-Commerce such
as user data, product items, product categories, product items, watch list, shopping car, and order list.
We need to design many functions based on a particular type of data. In the user module, there are
many functions based on user data such as Register, Login, Update password, and so on. Each
function should follow the following steps:
● Create database table
10
● Persistence Layer (SQL statements)
● Service layer
● Controller layer
● Front-end page
Data Persistence Layer: it is handled using the MyBatis framework, and this framework makes the
connectivity of data easier instead of using a traditional JDBC connection. This layer will be called by
business layer and interact with the database to request and store data.
Business Logic Layer: It is handled using the Spring framework and Spring MVC pattern. It
comprises two sub-layers such as service layer and controller layer. The service layer will call the
data persistence layer and the controller layer will call the service layer using annotation
@Autowired. It also helps handle the interaction with MyBatis persistence layer with help of DAO
components [2].
2.2.1 E-commerce Data Processing
We have a lot of data to process when we develop a web application. The priority of data
processing depends on how the complexity of the data. We usually deal with the simple data first and
then work on complex ones. In this application, I deal with user data first since users' data do not have
any dependency. And then I will process product category and product items. It has a lot of product
items under each category so it has a dependent relationship between those two collections of data. In
addition, shopping carts and watch list data are more complex, and the reason is they need to interact
with the user data tables and product item tables.
2.2.2 Function Components
Login Function
11
Figure 9 Login UI
This is login page and users can use their credential to login the E-commerce application.
Register function
Figure 10 Registration UI
This is Registration UI page, users can use this page to create user account with their username and
password, it will redirect to login page when account is created successfully.
Main Page
12
Figure 11 Main page part1
This main page of the E-commerce application. On the left-hand side, we have the “TW” logo,
this logo exists on different UI pages, and if users click this logo and it will help users redirect to the
main page. Our home button and cart button in the right-hand side, and there are user management
functions such as update info and address management under the home button. Users can also
check the items in the shopping cart before they purchase those items. In addition, the display
advertisement
board will randomly display some popular item for users.
Update Password
13
Figure 13 Update password UI
Users are able to update the password in the update password UI, and the password will be saved in the
t_user database.
Update Person Info
Users are able to update the user information such as username, phone number, gender, and email
address in the update Person info UI, and the new information will be saved in the t_user database.
Upload Image
Users are able to update the image in the upload image UI, and the path of new image will be saved
in
14
Shipping Management
Users are able to add new delivery address in the shipping management UI, and the new address
information will be saved in the t_address database.
Show Best Products function
The best match list will be shown in the main page, the product items information will be
retrieved from t_goods table and with help of JQuery frame work, all production information will
place in the UI.
15
Figure 18 Item description UI
The production information such as tile, price, and stocks will be retrieve from t_goods database
table and all products’ information will place in the UI. Once users click the “Add to cart”, and this
item will be added into shopping cart.
Once users click the “Add to cart”, this item will be added to the shopping cart, and users are able to
adjust the quality of the product and select some of the products and calculate the total price.
Once users click the total price, and then it will redirect to the confirm order UI. Users need to select
the delivery address and continue with the online pay button.
16
Payment Online
Once users proceed with the Confirm button, and then it will move to Pay success UI. Users are able to
see the success message in the UI.
2.2.3 MySQL Database Create
Figure 23 Databases
This is one example of entity class, and we need to create some entity classes for each of the tables.
Those entity class can be used to accept and transfer data.
2.2.5 MyBatis Persistence Layer
18
Figure 26 MyBatis .xml configuration
In this application, I create several MyBatis .xml files and I add many CRUD SQL statements in
each .xml file as shown in the figure 26. Each SQL statement will be mapped to one specific mapper
interface method.
2.2.6 Service Layer
19
Figure 28 Service implementation
In the service layer, all the business logic will be handled in those service classes, and each
service classes will integrate with mapper class and perform CRUD operations. Validation process
will also be handle in the service layer, and customize exception will be thrown when expected errors
happen
.
2.2.7 Controller Layer
CONCLUSION
This E-commerce online application is implemented by using the SSM framework. Spring Boot
reduces the work of configuration during development with IOC and AOP. It makes the development
productive when we use MVC as a design pattern. It also provides a very good environment for
communicating between the front-end and back-end. To achieve the communication, we can use
Spring JDBC, JPA, and DAO, supported by Spring ORM, Spring Data, and Spring Security. Finally,
Spring Boot also has an embedding HTTP server and inner database and testing tools for developers
to save their time. In conclusion, Spring Boot is a productive and powerful framework with those
built-in configurations, and that’s the reason that Spring Boot is popular for web development in
industries.
21
REFERENCES
[1] “Spring Web MVC Framework for rapid open source J2EE application development: a case
study”, International Journal of engineering Science and Technology.
[2] “Spring Framework: A Companion to JavaEE”
[3] Description from main website of Spring Boot Framework https://spring.io/
Rubrics
Concept 10
Planning and Execution/ 10
Practical Simulation/ Programming
Result and Interpretation 10
Record of Applied and Action Learning 10
Viva 10
Total 50
22