Defining a bean and its scope
Beans are Java objects that are managed by the IoC containers. The developer supplies the configuration metadata to an IoC container, which then uses the metadata to construct, assemble, and manage the beans. Each bean should have a unique identifier inside a container. A bean can even have more than one identity using an alias.
You can define beans using XML, Java, and annotations. Let’s declare a simple bean using a Java-based configuration:
public class SampleBean { public void init() { // initialization logic } public void destroy() { // destruction logic } // bean code } public interface BeanInterface { // interface code } public class BeanInterfaceImpl implements BeanInterface { // bean code } @Configuration public class AppConfig { @Bean(initMethod = "init", destroyMethod...