Brief introduction of spring core knowledge

1. What is spring?

Open source, layered, one-stop, lightweight framework

2.What are the core of spring?

1) ioc di
2) aop
3) transaction management
4) webFlux

3. What is the factory pattern? Is the spring bean factory a factory pattern? What is the difference?

An interface for creating objects, the
factory pattern is divided into simple factory pattern, factory method pattern and abstract factory pattern.

Difference: The bottom layer of the bean uses reflection.

4. What is ioc? There are several ways to configure ioc?

Inversion of Control
Method 1: XML-based configuration
Method 2: Annotation
Method 3: Java-based configuration

5. There are several ways to obtain ioc container, what is the difference?

1 XmlBeanFactory lazy loading
2 ApplicationContext instant loading
1) ClassPathXmlApplicationContext
2) FileSystemXmlApplicationContext
3 WebApplicationContext

6. Which method is used to obtain beans from the ioc container? There are several forms?

getBean() method
1)getBean(id)
2)getBean(class name.class)
3)getBean(class fully qualified name)
4)getBean(id, class fully qualified name)
5) getBean(class name.class, The fully qualified name of the class);

7. What is di? What are the ways of di

Dependency injection;
1) set method injection (xml, annotation)
2) construction method injection (xml, annotation)
3) factory method injection

8. What is aop?

aop: The method of the target object is implanted and enhanced through the technology of dynamic agent, so as to achieve the purpose of enhancing the method logic.

AOP is the abbreviation of Aspect Oriented Programming, which means: aspect-oriented programming, a technology that can dynamically and uniformly add functions to programs through pre-compilation and runtime dynamic agents without modifying the source code.

9. What is the underlying principle of aop?

The underlying principle of aop: dynamic proxy technology jdk dynamic proxy and cglib dynamic proxy

10.How to implement jdk dynamic proxy?

The jdk dynamic proxy uses the reflection mechanism to generate a proxy object, which is handed over to InvokeHandler for processing before calling the specific method. The
essence is to use byte splicing technology to automatically generate a proxy class $Proxy0 (subclass) for the interface

11. How to realize cglib dynamic proxy?

The cglib dynamic proxy is to use the jar package of asm to load the class file of the proxy object class and generate subclasses by modifying its bytecode; cover non-final methods to perform proxying.

CGLIB cannot proxy a final class or final method.

12. The difference between jdk dynamic agent and calib dynamic agent
区别:
	1.JDK动态代理只能对实现了接口的类生成代理,只针对接口实现类 。
	2.CGLIB是针对类实现代理,主要是对指定的类生成一个子类,覆盖其中的方法 。
13. What is the connection point of the concept in aop? What is the point of contact? What is the aspect? What is the notification?

What is implantation? What is a proxy? What is a target?

连接点           可以被增强的方法
    	切点              被增强的方法
    	通知/增强      增强的逻辑
    	切面              就是切点和通知(增强)的统称
    	植入              将通知植入到目标方法的过程
代理对象      调用被代理的对象,并且把返回结果再传给调用代理对象的对象。
    	目标对象       被增强的对象
14. What is a business?

Transaction: A group of logical operations, either all succeed or all fail; the purpose of the transaction is to solve the problem of [data inconsistency].

15. What are the 4 characteristics of transactions? ACID
        原子性:
        一致性:
        隔离性
        持久性:
16. What are the concurrency problems of transactions?

Dirty read
Non-repeatable read
Dummy read
Lost update

17. What are the isolation levels of transactions? What problems do they solve?
        未提交读:   以上情况都有可能发生。
        已提交读:   避免脏读,但不可重复读,虚读是有可能发生。
        可重复读:   避免脏读,不可重复读,但是虚读有可能发生。
        串行的:        避免以上所有情况.    系统吞吐量很低
18. What are the core interfaces of spring transaction management?

PlatformTransactionManager
TransactionDefinition
TransactionStatus

19. What is the difference between programmatic (manual) transaction and declarative transaction in spring? Which transaction method is generally used in development?
1.手动式针对单个方法进行增强,如果有多个方法,每个方法都要手动调用transactionTemplate
2. 声明式事务通过aop的原理进行增强方法的方式
20. How to implement declarative transactions?

Step 1: Which methods of the business layer require transactions (hacking).
Step 2: Configure the transaction manager in xml (different orm framework transaction management methods are different)
Step 3: Define the aspect in
the xml configuration Step 4: The xml configuration automatically generates the proxy object of the business method according to the cut point + enhancement

21. How to realize manual transaction?

Step 1: Which methods of the business layer require transactions (hacking).
Step 2: Configure the transaction manager in xml (different orm framework transaction management methods are different)
Step 3: Define the TransatcionTemplate transaction template class in the business class
Step 4: In the method that requires transaction management
Step 5: Test, Call the method of the business class

Guess you like

Origin blog.csdn.net/weixin_46822085/article/details/109024894