Wicket @SpringBean 不会创建可序列化的代理 [英] Wicket @SpringBean doesn't create serializable proxy

查看:36
本文介绍了Wicket @SpringBean 不会创建可序列化的代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@SpringBean
PDLocalizerLogic loc;

当使用上述时,我收到 java.io.NotSerializableException.这是因为 loc 不可序列化,但这应该不是问题,因为 spring bean 是可序列化的代理.我正在使用 wicket-spring 库,并作为注入器 SpringComponentInjector,其中 wrapInProxies 默认设置为 true,所以我认为应该创建代理,但它们不是.

When using above I receive java.io.NotSerializableException. This is because loc is not serializable, but this shouldn't be problem because spring beans are a serializable proxies. I'm using wicket-spring library, and as injector SpringComponentInjector, where wrapInProxies is by default set to true, so I think that proxies should be created, but they aren't.

在页面 https://cwiki.apache.org/WICKET/spring.html#Spring-AnnotationbasedApproach 是这样写的:

On the page https://cwiki.apache.org/WICKET/spring.html#Spring-AnnotationbasedApproach is written:

使用基于注释的方法,您不应该担心序列化/反序列化注入的依赖是这样的自动处理,依赖项表示为可序列化的代理

Using annotation-based approach, you should not worry about serialization/deserialization of the injected dependencies as this is handled automatically, the dependencies are represented by serializable proxies

我做错了什么?

推荐答案

你知道 bean 是如何被注入的吗?

Do you know how the bean is being injected?

  1. 通过组件初始化(即一个 Component 并由 SpringComponentInjector 填充)
  2. 其他一些使用 InjectorHolder.getInjector().inject(this) 的对象?
  3. 由 spring 直接注入(即这是一个 spring bean,其属性由 Spring 配置设置)

案例 1 和案例 2 将使用 wicket-spring 集成,并将使用可序列化的 wicket 代理包装 bean.案例 3 只会为您提供弹簧传递给您的任何东西,而无需包装.

Cases 1 and 2 would use wicket-spring integration and would wrap the bean with a wicket proxy which is serializable. Case 3 would only provide you whatever spring passes to you without wrapping.

这篇关于Wicket @SpringBean 不会创建可序列化的代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆