Can anyone tell me if there is a difference (in terms of spring bean injection and respecting singleton conditions or any other spring boot magic) in these two spring boot application classes?
@Bean
@Scope("singleton")
public UserService userService(Foo foo){
return new UserService(foo);
}
@Bean
@Scope("singleton")
public Foo foo(){
return new Foo();
}
AND calling not declaring Foo as a method parameter on userService() but rather injecting it via a direct method call to foo()
@Bean
@Scope("singleton")
public UserService userService(){
return new UserService(foo());
}
@Bean
@Scope("singleton")
public Foo foo(){
return new Foo();
}