0% found this document useful (0 votes)
53 views21 pages

04 Spring

This document provides an overview of the Spring framework. It discusses what Spring is, the advantages of using Spring, an exploration of Spring containers and modules, an introduction to Spring Boot, and how to create and run a simple Spring Boot application. Key topics covered include dependency injection, loose coupling, and auto-configuration in Spring Boot.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views21 pages

04 Spring

This document provides an overview of the Spring framework. It discusses what Spring is, the advantages of using Spring, an exploration of Spring containers and modules, an introduction to Spring Boot, and how to create and run a simple Spring Boot application. Key topics covered include dependency injection, loose coupling, and auto-configuration in Spring Boot.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

SPRING BY L. A. N.

Yapa
OUTLINE
What is a Framework

Advantages of using Framework

Explore Spring container and modules

Spring Boot

Create and Run Spring boot Application.


Spring is lightweight framework.
Spring is the most popular application development
framework for enterprise Java. Millions of developers
around the world use Spring Framework to create high
OVERVIEW performing, easily testable, and reusable code.
Spring framework targets to make Java EE development
easier to use and promotes good programming practices
BENEFITS OF USING THE SPRING FRAMEWORK
Spring enables developers to develop enterprise-class applications using POJOs. The benefit of using only POJOs is that you do
not need an EJB container product such as an application server, but you have the option of using only a robust servlet container
such as Tomcat or some commercial product.

Spring achieves the loose coupling through dependency injection and interface-based programming.

Spring provides an abstraction layer on existing technologies like servlets, jsps, jdbc, jndi, rmi, jms and Java mail etc., to simplify the
development process.

Spring comes with some of the existing technologies like ORM framework, logging framework.

Easy to test - The Dependency Injection makes easier to test the application. The EJB or Struts application require server to run the
application, but Spring framework doesn't require server.

Fast Development - The Dependency Injection feature of Spring Framework and it support to various frameworks makes the easy
development of Java EE application.
SPRING
FRAMEWORK
ARCHITECTURE
CORE CONTAINER The Core module provides the fundamental parts
of the framework, including the IoC and
Dependency Injection features.

The Core Container consists of the Core, Beans, The Bean module provides BeanFactory, which is a
Context, and Expression Language modules sophisticated implementation of the factory
pattern.

The Context module builds on the solid base


provided by the Core and Beans modules and it is
a medium to access any objects defined and
configured. The ApplicationContext interface is the
focal point of the Context module.

The SpEL module provides a powerful expression


language for querying and manipulating an object
graph at runtime.
DATA ACCESS/ The JDBC module provides a JDBC-abstraction layer that
removes the need for tedious JDBC related coding.
INTEGRATION
The ORM module provides integration layers for popular
The Data Access/Integration layer consists of the object-relational mapping APIs, including JPA, Hibernate and
JDBC, ORM, OXM, JMS and Transaction modules iBatis.

The OXM module provides an abstraction layer that supports


Object/XML mapping implementations for JAXB, Castor,
XMLBeans, JiBX and XStream.

The Java Messaging Service JMS module contains features for


producing and consuming messages.

The Transaction module supports programmatic and


declarative transaction management for classes that implement
special interfaces and for all your POJOs.
WEB The Web module provides basic web-oriented integration
features such as multipart file-upload functionality and the
initialization of the IoC container using servlet listeners and
a web-oriented application context.
The Web layer consists of the Web, Web-
MVC, Web-Socket, and Web-Portlet modules
The Web-MVC module contains Spring's Model-View-
Controller (MVC) implementation for web applications.

The Web-Socket module provides support for WebSocket-


based, two-way communication between the client and the
server in web applications.

The Web-Portlet module provides the MVC implementation


to be used in a portlet environment and mirrors the
functionality of Web-Servlet module.
The AOP module provides an aspect-oriented programming
implementation allowing you to define method-interceptors
and pointcuts to cleanly decouple code that implements
functionality that should be separated.
The Aspects module provides integration with AspectJ,
which is again a powerful and mature AOP framework.
The Instrumentation module provides class instrumentation

MISCELLANEOUS support and class loader implementations to be used in


certain application servers.
There are few other important The Messaging module provides support for STOMP as the
modules like AOP, Aspects, WebSocket sub-protocol to use in applications. It also
Instrumentation, Web and Test modules
supports an annotation programming model for routing and
processing STOMP messages from WebSocket clients.
The Test module supports the testing of Spring components
with JUnit or TestNG frameworks.
SPRING BOOT
Spring Boot is an open source Java-based
framework used to create a micro Service. It is
developed by Pivotal Team and is used to build
stand-alone and production ready spring
applications.
Spring Boot provides a good platform for Java
developers to develop a stand-alone and
production-grade spring application that you can
just run. You can get started with minimum
configurations without the need for an entire Spring
configuration setup.
ADVANTAGES

Easy to understand and develop spring applications

Increases productivity

Reduces the development time


▪ It provides a flexible way to configure Java Beans,
XML configurations, and Database Transactions.
▪ It provides a powerful batch processing and
manages REST endpoints.
WHY SPRING ▪ In Spring Boot, everything is auto configured; no
BOOT? manual configurations are needed.
▪ It offers annotation-based spring application
▪ Eases dependency management
▪ It includes Embedded Servlet Container
HOW DOES IT WORK?
Spring Boot automatically configures your application based on the
dependencies you have added to the project by using
@EnableAutoConfiguration annotation. For example, if MySQL
database is on your classpath, but you have not configured any
database connection, then Spring Boot auto-configures an in-memory
database.
The entry point of the spring boot application is the class contains
@SpringBootApplication annotation and the main method.
Spring Boot automatically scans all the components included in the
project by using @ComponentScan annotation.
SPRING BOOT STARTERS
Handling dependency management is a difficult task for big projects. Spring
Boot resolves this problem by providing a set of dependencies for
developer's convenience.
For example, if want to use Spring and JPA for database access, it is
sufficient if include spring-boot-starter-data-jpa dependency in the project.
Note that all Spring Boot starters follow the same naming pattern spring-
boot-starter- *, where * indicates that it is a type of the application.
Examples
Spring Boot Starter Actuator dependency is used to monitor and manage
application.
SPRING BOOT
STARTERS EXAMPLE
HOW TO CREATE
SIMPLE SPRING
BOOT APPLICATION
Go to “Spring Initializr” web page
(https://start.spring.io/)
1. CREATE SPRING BOOT PROJECT
WITH BASIC CONFIGURATION
2. DOWNLOAD THE PROJECT AND EXTRACT THE ZIP FILE.
3. OPEN THE PROJECT USING NETBEANS IDE.
SPRING BOOT
APPLICATION
create a web controller for a simple
web application.
DEMO
THANK YOU Q&A

You might also like