Spring bean tag properties (attributes)

Spring bean tag properties (attributes)

In spring the beans are managed by Spring IoC container, these are backbone of the application. You can instantiate and manage them in your application using configurations. In xml based spring bean configurations, using <bean> tag, you can manage them. Here we have given complete list of bean tag properties:

name / id:
This attribute specifies the bean unique identifier. In XML based configuration metadata, you use the id and/or name attributes to specify the bean identifier.

class:
This attribute is mandatory and specify the bean class to be used to create the bean. You should specify fully qualified class name. Include package name.

scope:
This attribute specifies the scope of the objects created from a particular bean definition. The scope values can be prototype, singleton, request, session, and global session.

constructor-arg:
This is used to inject the dependencies through bean constructor.

properties:
This attribute is used to inject the dependencies through setter method.

autowiring mode:
This is used to inject the dependencies.

lazy-init (lazy-initialization mode):
A lazy-initialized bean tells the IoC container to create a bean instance when it is first requested, rather than at startup.

init-method (initialization method):
A callback to be called just after all necessary properties on the bean have been set by the container. This is part of bean lifecycle.

destroy-method (destruction method):
A callback to be used when the container containing the bean is destroyed. This is part of bean lifecycle.



Properties
Description
class
This attribute is mandatory and specify the bean class to be used to create the bean.
name
This attribute specifies the bean identifier uniquely. In XML-based configuration metadata, you use the id and/or name attributes to specify the bean identifier(s).
scope
This attribute specifies the scope of the objects created from a particular bean definition and it will be discussed in bean scopes chapter.
constructor-arg
This is used to inject the dependencies and will be discussed in next chapters.
properties
This is used to inject the dependencies and will be discussed in next chapters.
autowiring mode
This is used to inject the dependencies and will be discussed in next chapters.
lazy-initialization mode
A lazy-initialized bean tells the IoC container to create a bean instance when it is first requested, rather than at startup.
initialization method
A callback to be called just after all necessary properties on the bean have been set by the container. It will be discussed in bean life cycle chapter.
destruction method
A callback to be used when the container containing the bean is destroyed. It will be discussed in bean life cycle chapter.



Comments

Popular posts from this blog

પટેલ સમાજનો ઈતિહાસ જાણો : કોણ અને ક્યાંથી આવ્યા હતા પાટીદારો

Python HTML Generator using Yattag Part 1

Java Event Delegation Model, Listener and Adapter Classes