Category: Spring Framework
Spring Bean Scopes – Singleton vs Prototype
When creating bean definitions you cannot only control various dependencies and configurations, but also define the scope of the bean. These scopes are configured via configuration which makes them very powerfull and flexible. You...
Lazy Initialize @Autowired Dependencies with @Lazy
By default all autowired dependencies are eagerly created and configured at startup. When the @Lazy annotation is present together with the @Component annotation on class level, then the component will not be eagerly created...
Lazy Initialize Spring Bean XML Configuration
By default spring container eagerly creates and configures all singleton beans. In most cases this is desirable, because errors and exceptions are discovered at startup time rather than runtime. When this behavior is not...
Spring Exclude Bean From Autowiring
This tutorial shows you how to exclude beans from autowiring. The <beans/> element has a autowire-candidate attribute which you can set to false to tell the container to make the bean unavailable for autowiring....
Spring Autowire beans with @Autowired Annotation
This tutorial shows how to use the @Autowired annotation. The @Autowired annotation marks a constructor, field, setter method or config methods as to be autowired for the spring container. Beans We are using these...
Spring Autowire By Constructor
This tutorial shows how to use spring autowire by constructor. When the autowire by constructor is enabled -which is actually analogous to autowire by type, but applies to constructor arguments- spring will autowire a...
Spring Autowire By Type
This tutorial shows how to use spring autowire by type. When the autowire by type is enabled, spring will autowire a property if exactly one bean of the property type exists in the container....
Spring Autowire By Name
This tutorial shows how to use spring autowire by name. When the autowire by name is enabled, spring will look for a bean with the same name as the property that needs to be...
Loading List from Properties file with spring @Value
This example shows you how to load a list from a properties file using the @Value annotation. In this tutorial we’ll be using the comma as a separator. But you can use any delimiter...