Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common interview questions in Spring?

2025-02-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what are the common interview questions in Spring". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. What is it?

Spring is a lightweight application framework based on JEE.

two。 What?

Functions of each package:

Web framework provided by WEBMVC:spring itself

WEB: a framework for integrating web applications

JEE: inherits a series of jee technologies

DAO: encapsulates JDBC

ORM: provides integration with ORM tools

AOP: weave facing the tangent plane

CORE:spring core package, providing bean factory and IOC containers

3. What can I do?

Effectively combine a list of jee technologies to form a good system.

4. Containers and bean

Bean: objects managed by spring and ioc are called bean

Containers: (analogy with jee containers)

Jee: provides the operating environment for components and manages the lifecycle of components (cannot exist alone)

Spring: provides the operating environment for bean and the lifecycle for managing bean (which can exist separately)

5.IOC control inversion

In the past, if the application wanted to get an instance of A, he would directly take the initiative to get it. After using sping, the application changed from active fetching to passive waiting, and spring controlled the objects needed by the application.

Advantages of 1.IOC

1. You can get an instance through IOC

two。 The injected resources can be obtained through DI

two。 Principles for configuring IOC

1. Dependency injection must be used for variable resources.

two。 Dependency injection must be the interface between layers or the mutual calls between modules.

3. The presentation layer calls the logic layer, which allows the presentation layer to act as a client instead of dependency injection. The presentation layer only needs one resource for the logic layer interface.

6.DI dependency injection

1. The objects IOC and DI needed for an application to rely on spring injection are different descriptions of the same thing.

2.setter injection: configure the implementation of the interface in the configuration file to bean injection in the application

3. Constructor injection

4.singleton

1. The singleton pattern is that there is only one instance in the entire jvm

Singleton of 2.spring means that there is only one instance in the container of spring and only one instance in a lifecycle.

Advantages of 5.DI:

1. Program waiting passively, strengthening interface-oriented programming

two。 Cut off the connection between objects or components, making the structure of the program more loose and easier to run and maintain.

7.Aop aspect-oriented programming

1.AOP aspect-oriented programming some good patterns or examples-normal form

Aspect: a section represents a series of common function points (common function points between modules) that we are concerned with.

The idea of 2.AOP: active-> passive (additional function)

The concept of 3.AOP

1. Aspect: the functional points we are concerned with

two。 Connection point: the trigger point of the event (execution of the method)

3. Notification: action performed when the connection point is triggered (method)

4. Pointcut: a collection of connection points (modularization of connection points)

5. Introduction: extended featur

6. Target objects: objects that contain connection points

7.aop proxy: implementation mechanism

8. Use annotations

1.@Aspect declares an aspect, defining a series of common functions as an aspect

Define @ Aspect directly on the class

2.@Pointcut declaration pointcut

Use a special class to define the pointcut, and the method name in the class is the name of the pointcut

3.@Aronud

Note @ Around surround append function

Append functions before and after executing the methods of the target object

Must have a parameter; the first parameter must be of type ProceedingJoinPoint

Call the method of the monitored target object through the proceed of the instance of ProceedingJoinPoint

Define a pointcut that is referenced by the method name as the name of the pointcut

4.@Before

Note @ Before appends the corresponding function before executing the method of the target object

Define a pointcut that is referenced by the method name as the name of the pointcut

5.@After

Note @ After appends the corresponding function after executing the method of the target object

Define a pointcut that is referenced by the method name as the name of the pointcut

6.@Transcational

Point to where to hit (either on the class or on the method)

Transaction management also needs to be injected into dataSource and spring

This is the end of the content of "what are the common interview questions for Spring". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report