Spring可序列化的代理(Spring serializable proxy)

编程入门 行业动态 更新时间:2024-10-27 15:21:38
Spring可序列化的代理(Spring serializable proxy)

我有弹簧会话范围的bean。 该bean正在使用应用程序范围的bean,并且在容器尝试序列化会话时出现错误。

我记得JSF应用程序的问题,在一个项目中,我们已经解决了使用可序列化代理的问题。 注入的bean是从应用程序上下文中获取单例实例的代理包装器。 不幸的是,我不记得它是如何被调用的,它是一个内置的解决方案还是一些外部的东西。

如何在可序列化的代理中包装Spring bean? Spring是否提供这样的功能? AFAIR有一些特殊的注释来标记应该包含在这种代理中的引用。

I have spring session scoped bean. That bean is using application scoped beans, and there's and error when the container tries to serialize the session.

I remember that problem from JSF applications, and in one project, we've solved that using serializable proxies. The injected bean was the proxy wrapper which fetched the singleton instance from the application context. Unfortunately, I can't remember how exactly it was called and was it a build-in solution or some external thing.

How to wrap spring beans in serializable proxies? Does Spring provide such functionality? AFAIR there was some special annotation to mark the references that should be wrapped in such proxy.

最满意答案

该功能被称为作用域代理 ,可以通过对服务的注释来触发,该注入将被注入会话限定范围的bean:

@Scope(proxyMode = ScopedProxyMode.INTERFACES)

问题的更多细节:

就序列化而言,Spring会话范围的bean(控制器)和对服务的引用

The feature is called scoped proxy and can be triggered via annotation to the service, that will be injected to session scoped beans:

@Scope(proxyMode = ScopedProxyMode.INTERFACES)

More details in question:

Spring session-scoped beans (controllers) and references to services, in terms of serialization

更多推荐

本文发布于:2023-08-01 04:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1352932.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:序列化   Spring   proxy   serializable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!