1
我有以下代码来在我的Spring应用程序中定义一个bean请求作用域bean。当请求范围不可用时,请求作用域bean singleton
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public MyBean myBean() {
return new MyBean(); // actually it is a more complex initialization
}
但有时我会想在脱机应用程序使用同一个bean那里request
范围不可,只有singleton
和prototype
是。
当request
不可用时,是否有办法使这个相同的bean假定为singleton
表单?
它非常好。我以前使用'@ Profile'。 –