Wicket @SpringBean 不会创建可序列化的代理

编程入门 行业动态 更新时间:2024-10-17 19:20:55
本文介绍了Wicket @SpringBean 不会创建可序列化的代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..
@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/WICKET/spring.html#Spring-AnnotationbasedApproach 是这样写的:

On the page https://cwiki.apache/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?

通过组件初始化(即一个 Component 并由 SpringComponentInjector 填充)其他一些使用 InjectorHolder.getInjector().inject(this) 的对象?由 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屋!

更多推荐

[db:关键词]

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

发布评论

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

>www.elefans.com

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