Bean Definition Inheritance

Why do we need it? Used for common set of definitions across multiple beans Inherit bean definition across other beans Can be a bean itself Can be an abstract bean, just to be overridden Example config.xml [code language=”xml”] <bean id=”parentbean” class=”…”> <property name=”commonPropertyName” value=”commonValue” /> </bean> <bean id=”childA” class=”…” parent=”parentbean”> <property name=”childAPropertyName” value=”childAValue” /> </bean> …

Bean Definition Inheritance Read More »

Spring Bean Scopes

singleton (default) only one instance per Spring Container prototype any number of instances request scoped to an HTTP request (web-aware Spring ApplicationContext) session scoped to an HTTP session (web-aware Spring ApplicationContext) global-session scoped to a global HTTP session (web-aware Spring ApplicationContext) <bean id=”helloWorld” class=”Hello” scope=”singleton”> </bean> <bean id=”helloWorld” scope=”prototype”> </bean>