Home Java javaTutorial Introducing the common properties of springioc beans

Introducing the common properties of springioc beans

Sep 11, 2017 am 11:30 AM
bean Attributes

The following editor will bring you an introduction to several properties based on springioc beans. The editor thinks it’s pretty good, and now I want to give it to you and give it as a reference. Let’s follow the editor and take a look.

1.lazy-init="false"

The default value is false, which refers to the bean The creation timing of the spring container will load these classes as soon as it starts. One of the advantages is to find bean-related errors in time. Because the spring container starts, the beans will also be created. If there are any errors in the beans, they will be reported. The disadvantage is that if the overhead of the bean object If it is larger, it will occupy memory in advance.

If set to true, it will not be created until the spring container obtains the object of the bean. The advantages and disadvantages are opposite to false

2.scope="singleton"

The default value is singleton, which means that the bean object in the spring container is singleton by default. At this time, due to thread safety issues, Avoid attribute sharing

If set to prototype, it means multiple instances. At this time, no matter lazy-init is invalid, it will be lazy loading.

3.init-method=""

Called after executing the bean's constructor and before calling the specific method of the bean

4.destory-method=""

Called when the spring container is closed or destroyed (singleton mode only)

The above is the detailed content of Introducing the common properties of springioc beans. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to get integer literal properties in Python without SyntaxError? How to get integer literal properties in Python without SyntaxError? Aug 20, 2023 pm 07:13 PM

TogetintliteralattributeinsteadofSyntaxError,useaspaceorparenthesis.TheintliteralisapartifNumericLiteralsinPython.NumericLiteralsalsoincludesthefollowingfourdifferentnumericaltypes−int(signedintegers)−Theyareoftencalledjustintegersorints,arepositiveo

How does SpringBoot delete useless beans in referenced jar packages? How does SpringBoot delete useless beans in referenced jar packages? May 14, 2023 pm 08:07 PM

Preface: The company has a project that is in a hurry, and some of the project's requirements are the same as some of the functions of previous projects. In order to speed up and directly introduce some modules in the previous multi-module maven project in the form of jar packages. The new project was launched. Although it saved a lot of development time, it also caused the project to need to import the related dependencies of the project jar, causing the project to be bloated and slow to start. Is there a way to make the project load only the beans it needs? Of course, we can directly modify the source code and repackage it to solve the problem, but this method is too troublesome. Through Baidu's method, the query can use the @ComponentScan annotation on the springboot startup class to implement the code example @Componen

How to rename properties of JSON using Gson in Java? How to rename properties of JSON using Gson in Java? Aug 27, 2023 pm 02:01 PM

The Gson@SerializedName annotation can be serialized to JSON and have the provided name value as its field name. This annotation can override any FieldNamingPolicy, including the default field naming policy that may have been set on the Gson instance. Different naming strategies can be set using the GsonBuilder class. Syntax@Retention(value=RUNTIME)@Target(value={FIELD,METHOD})public@interfaceSerializedNameExample importcom.google.gson.annotations.*;

Python's dir() function: View the properties and methods of an object Python's dir() function: View the properties and methods of an object Nov 18, 2023 pm 01:45 PM

Python's dir() function: View an object's properties and methods, specific code example required Summary: Python is a powerful and flexible programming language, and its built-in functions and tools provide developers with many convenient features. One of the very useful functions is the dir() function, which allows us to view the properties and methods of an object. This article will introduce the usage of the dir() function and demonstrate its functions and uses through specific code examples. Text: Python’s dir() function is a built-in function.

Java Spring framework creation project and Bean storage and reading example analysis Java Spring framework creation project and Bean storage and reading example analysis May 12, 2023 am 08:40 AM

1. Creation of Spring project 1.1 Creating a Maven project The first step is to create a Maven project. Spring is also based on Maven. 1.2 Add spring dependencies The second step is to add Spring support (spring-context, spring-beans) to the Maven project and add dependencies in the pom.xml file. org.springframeworkspring-context5.2.3.RELEASEorg.springframeworkspring-beans5.2.3.RELEASE refreshes and waits for loading to complete. 1.3 Create startup class The third step is to create

What to do if Win11 disk properties are unknown What to do if Win11 disk properties are unknown Jul 03, 2023 pm 04:17 PM

What should I do if the disk properties of Win11 are unknown? Recently, Win11 users found that the system prompted a disk error when using their computers. What is going on? And how to solve it? Many friends don’t know how to operate in detail. The editor has compiled the steps to solve the Win11 disk error below. If you are interested, follow the editor to read below! Steps to solve Win11 disk error 1. First, press the Win+E key combination on the keyboard, or click the File Explorer on the taskbar; 2. In the right sidebar of the File Explorer, find the side and right-click the local disk (C :), in the menu item that opens, select Properties; 3. Local disk (C:) Properties window, switch to Tools

How does SpringBoot select me first when loading beans? How does SpringBoot select me first when loading beans? May 15, 2023 pm 09:13 PM

1. Applicable scenarios If we need to manage the startup sequence of specific beans in all hierarchies of the application. For example, you need to initialize a bean when the application starts. If the beans in our public library are used by other developer services, but they need to customize beans in some scenarios, we need to load the beans in the public library before these customized beans. 2. Three implementation methods In SpringBoot applications, we can adopt the following three methods to achieve priority loading of our own beans: 1. @Configuration annotation + @DependsOn annotation @Configuration annotation in SpringBoo

Detailed explanation of Bean acquisition methods in Spring Detailed explanation of Bean acquisition methods in Spring Dec 30, 2023 am 08:49 AM

Detailed explanation of the Bean acquisition method in Spring In the Spring framework, Bean acquisition is a very important part. In applications, we often need to use dependency injection or dynamically obtain instances of beans. This article will introduce in detail how to obtain beans in Spring and give specific code examples. Obtaining the Bean@Component annotation through the @Component annotation is one of the commonly used annotations in the Spring framework. We can do this by adding @Compone on the class

See all articles