Simple instance of spring IOC and scope attribute resolution of bean

IOC (inversion if control) - inversion of control is one of the two core technologies of spring. IOC is generally divided into two types: dependency injection (DI) and dependency lookup

Use example:

1. Create a new project and import the spring related jar package.

2. New data access layer and business logic layer

Code structure:

Code example:

3. Write ApplicationContext XML configuration file

Header information:

Configuration code:

Test code:

In the above example code, we use set method injection. There are many injection methods in spring, and there are many injected attribute types. Please refer to:

On the injection mode of spring IOC and different data types

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>