The documentation says that the default bean scope for Spring is a singleton.
I couldn't find anything about method level injections bypassing this scope.
With this configuration
@Configuration
public class ApplicationConfiguration {
@Bean
public ModuleProvider getModuleProvider() {
return new ModuleProvider();
}
}
Method One (which I expect for both outcomes):
@RestController
@Scope(value = "request")
@RequestMapping(value = "/application")
public class ApplicationController {
@Autowired
ModuleProvider moduleProvider;
@RequestMapping
public String showModules() {
return moduleProvider.toString();
}
}
Hitting it twice, the output is..
application.ModuleProvider@673f63cb
application.ModuleProvider@673f63cb
Method Two:
@RestController
@Scope(value = "request")
@RequestMapping(value = "/application")
public class ApplicationController {
@Autowired
@RequestMapping
public String showModules(ModuleProvider moduleProvider) {
return moduleProvider.toString();
}
}
Hitting it twice, the output is..
application.ModuleProvider@1cc4fbcb
application.ModuleProvider@57248dbf