Spring Configurations
What is Spring Configurations?
-
In Spring; configurations refers to the "instructions" and "setup" that are provided to the Spring Container.
-
Some basic spring configurations are :-
- What beans should be created (eg. service classes, repositories)
- How beans should be wired or connected (dependency injection)
- Scope of beans (eg. singleton, prototype)
- Life cycle methods (initialization and destruction methods)
- (and many more configurations which are explained below)
-
According to the provided configurations, Spring Container performs the particular task.
Important Configurations in Spring :
Below are some commonly used configurations in spring :-
- Bean Configurations : Bean Configurations defines the beans (objects) that Spring will manage, including their properties, dependencies and lifecycle methods. It specify how beans are instantiated and injected into each other.
- Autowiring Configurations : Autowiring Configurations manages dependency injection automatically by wiring beans based on type, name, or explicitly with annotations like @Autowired, @Qualifier, or @Inject.
- AOP Configurations : AOP Configurations configures aspects and advice for handling cross-cutting concerns such as logging, transactions, and security. This can include defining aspects, pointcuts, and advice types.
- Database Configurations : Database Configurations configures the data sources, connection pools and Hibernate/JPA settings for interacting with databases. This often includes setting up properties like database URL, username, password, and Hibernate dialect.
- Transaction Management Configurations : Transaction Management Configurations configures transactional behavior for methods interacting with databases, using @Transactional annotations or XML configurations. Specifies when transactions begin, commit, or roll back.
- MVC Configurations : MVC Configurations configures settings related to the Spring MVC framework, including view resolvers, handler mappings, interceptors, and static resource handling.
- Security Configurations : Security Configurations Configures application security settings, including authentication, authorization, and access control. Security configurations may specify user roles, authentication providers, and access restrictions.
- Profile Configurations : Profile Configurations allows configurations based on different environments (e.g. development, testing, production). By setting profiles, Spring loads specific beans or properties depending on the active environment.
- Caching Configurations : Caching Configurations enables caching in the application using @EnableCaching. This allows caching results of methods or components to improve performance.
- Scheduling Configurations : Configures tasks to run at scheduled intervals using @EnableScheduling and @Scheduled annotations.
These are only some common configurations that we provide in spring applications. As you keep reading further and creating more programs, you will understand these configurations more deeply...!!
How to Provide Configurations ?
Spring provides three main ways for configurations :-
1. XML-based Configuration
2. Java-based Configuration
3. Annotations-based Configuration
-
1. XML-based Configuration
-
2. Java-based Configuration
-
3. Annotations-based Configuration
Spring Framework (Including Advance Java)
₹2,999
₹7,999
Spring Boot Framework (with 1 project)
₹3,999
₹8,999
Core Java Development (6 Projects + Interview Preparation)
₹2,499
₹6,999
DSA using Java (LeetCode + Problem Solving)
₹3,999
₹8,999
Advance Java (JDBC, Servlet, JSP & 1 Project)
₹2,999
₹7,999
Java Backend Development (With 6 Projects)
₹6,999
₹15,999
Java Full Stack Development (with 7 Projects)
₹7,999
₹17,999
Spring Framework (Including Advance Java)
₹2,999
₹7,999
Spring Boot Framework (with 1 project)
₹3,999
₹8,999
Core Java Development (6 Projects + Interview Preparation)
₹2,499
₹6,999
DSA using Java (LeetCode + Problem Solving)
₹3,999
₹8,999
Advance Java (JDBC, Servlet, JSP & 1 Project)
₹2,999
₹7,999
Java Backend Development (With 6 Projects)
₹6,999
₹15,999
Java Full Stack Development (with 7 Projects)
₹7,999
₹17,999