Dewa
Dewa

Reputation: 33

How Spring Container manage if 2 same bean have different id/name

How Many Objects will be created into container. if configuration will be as given below.

<bean id = "helloWorld" class = "com.tutorialspoint.HelloWorld"><br/>
  <property name = "message" value = "Hello World"/>
</bean>

<bean id = "helloWorld1" class = "com.tutorialspoint.HelloWorld">
  <property name = "message" value = "Hello World"/>
</bean>

Upvotes: 0

Views: 128

Answers (1)

prost&#253; člověk
prost&#253; člověk

Reputation: 939

One singleton object per definition in the spring container, if you define N beans then N singleton object of the class will be created.

It will create two instances in your case, by definition Spring container creates a singleton instance per bean.

Upvotes: 1

Related Questions