@Component
@Qualifier("impl1")
public class Implementation1 implements BaseInterface{
@Override
public String process() {
return "Implementation1";
}
}
@RestController
public class HomeController {
@GetMapping("/impl1")
@Autowired
public String impl1(@Qualifier("impl1")Implementation1 impl) {
return impl.process()+" "+impl.hashCode();
}
}
By default all the beans are supposed be of singleton scope in spring boot application, and so I suppose their hashCode should be same as well. But that is not the case for me. Please let me know if I am missing something here.
Above are the Controller and Bean class, BaseInterface is a simple interface with process() abstract method. Yet for each Request I am getting a different hashCode. Had it been treated as a singleton the hashCOde should have been same for each request.
I expect there to be same hash code each time