我有弹簧会话范围的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更多推荐
发布评论