如果@Bean方法返回新对象,它会导致内存泄漏?
我有这样的java代码。
public class feignConfiguration {
@Bean
public RequestInterceptor requestInterceptor() {
return new HeaderInterceptor();
}
}
我知道Spring容器保存所有的bean,并且默认情况下所有bean的范围都是“单例”。
但代码看起来每次请求拦截时都会创建对象。
所以我应该知道它是否会导致内存泄漏或其他原因。
I have java code like this.
public class feignConfiguration {
@Bean
public RequestInterceptor requestInterceptor() {
return new HeaderInterceptor();
}
}
I know that Spring container holds all the beans and the scope of all the beans is "singleton" by default.
But the code looks like every time request intercepts, object creates.
So I should know whether it causes memory leak or something else.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论