Changing scopes to @Component annotated class

In this post under Spring Core, I will show with example how to change the scope of class annotated with “@Component” annotation. By default whenever we annotate a class with “@Component” annotation the scope of the bean is set to “singleton”. We can change this by the help of “@Scope” annotation which is also applied…… Continue reading Changing scopes to @Component annotated class

Spring @Component and @ComponentScan annotation example

In this post under Spring Core, I will show with example the purpose and how to use “@Component” and “@ComponentScan” annotation together. Till now in all my previous post, I have been defining a bean using “@Bean” annotation in an “@Configuration” annotated class as shown below package package1;import org.springframework.context.ApplicationContext;import org.springframework.context.annotation.AnnotationConfigApplicationContext;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class Example1 {…… Continue reading Spring @Component and @ComponentScan annotation example