0% found this document useful (0 votes)
2 views9 pages

Spring Framework

The Spring Framework, created by Rod Johnson and released in 2003, is a popular choice among Java developers for managing object relationships through dependency injection and inversion of control. It features an IoC container that configures and connects objects, allowing for flexible bean management via XML or annotations like @Component and @Autowired. Additionally, Spring simplifies database interactions and transaction management with default JDBC templates and the @Transactional annotation, which handles transaction propagation automatically.

Uploaded by

ananya s
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)
2 views9 pages

Spring Framework

The Spring Framework, created by Rod Johnson and released in 2003, is a popular choice among Java developers for managing object relationships through dependency injection and inversion of control. It features an IoC container that configures and connects objects, allowing for flexible bean management via XML or annotations like @Component and @Autowired. Additionally, Spring simplifies database interactions and transaction management with default JDBC templates and the @Transactional annotation, which handles transaction propagation automatically.

Uploaded by

ananya s
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/ 9

SPRING

Framework

musanabiyev

nebiyevmusa
Spring is the most preferred
framework by Java application
developers. It was written by
Rod Johnson and first released
in June 2003 under the Apache
2.0 license. The main goal of the
Spring framework is to ensure
that the management of Java
object relations is entirely
managed by the infrastructure,
not by developers.

1
The Spring framework was
developed based on the principle
that code should be as
independent as possible from
object relationships. It uses the
principles of dependency injection
and inversion of control to manage
object relationships and provides
us with a very powerful abstraction
environment thanks to the
submodules defined within it.

2
In the Spring framework, there is an
IoC container in the Spring Core
module. The IoC container is the
main component that Spring uses
to manage object relationships,
and dependency injection is the
method used to implement IoC.
The IoC container configures
objects and establishes
connections between objects when
the application is up. There are
more than one way to configure
our spring beans in the spring
container. We can do it in an XML
configuration file or by adding
annotations to classes.

3
The main annotation managed by
the Spring container is the
@Component annotation, and the
@Controller, @Repository, and
@Service annotations that we need
to use in various places in the
application are subclasses of the
@Component annotation.
We need to find the beans to be used
when the Spring application starts up
and create their proxy objects one by
one. We can present the beans we
need to spring in different ways, we
can define beans in the xml
configuration file or automatically
scan the beans of spring we can use
the find feature to do.

4
For this we can use
@ComponentScan and define the
main package structures within this
annotation.When we want to get a
Spring bean object managed by
Spring, we use the @Autowired
annotation. When Spring sees this
annotation, it injects the previously
created spring proxy object into the
reference under the @Autowired
annotation with Dependency
Injection.

5
Every time @Autowired is called, the
spring IoC container returns us a
spring proxy object, whether this
spring proxy object should return a
pre-created object or create a new
object on each request is decided
by looking at the scope reference in
the spring bean.
For example, if our bean scope
record is a singleton, object of that
class will be created only once
while the application is running.
If our scop record is prototype,
every time we request a bean from
the IoC container, it creates and
returns a new bean object to us.

6
With Spring Framework default
JDBC Hibernate JPA templates, it
saves the developer from many
problems that he has to solve when
working with databases, such as
exception handling, connection
establishment, and transaction
management. @Transactional
annotation is used to manage the
transaction. After adding this
annotation, database connection,
transaction initiation, and when our
transaction method ends, the
commit or rollback of this
transaction is handled by Spring in
the background.

7
Spring takes the propagation
parameter into the @Transactional
annotation to handle the
transaction propagation. By
default, this is required, that is,
when the method containing the
@Transactional annotation works, if
there is an existing transaction, it
uses this transaction without
opening a new transaction, if there
is no transaction, it opens a new
transaction.

You might also like