@SpringBean
PDLocalizerLogic loc;
使用上述方法时,我收到 java.io.NotSerializableException。这是因为 loc 不可序列化,但这应该不是问题,因为 spring bean 是可序列化的代理。 我正在使用 wicket-spring 库,并作为注入(inject)器 SpringComponentInjector,其中 wrapInProxies 默认设置为 true,所以我认为应该创建代理,但它们不是。
在页面上https://cwiki.apache.org/WICKET/spring.html#Spring-AnnotationbasedApproach写成:
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是怎么注入(inject)的吗?
- 通过组件初始化(即一个组件并由 SpringComponentInjector 填充)
- 使用 InjectorHolder.getInjector().inject(this) 的其他对象?
- 由 spring 直接注入(inject)(即这是一个 spring bean,其属性由 Spring 配置设置)
案例 1 和案例 2 将使用 wicket-spring 集成,并使用可序列化的 wicket 代理包装 bean。 情况 3 只会为您提供任何 spring 传递给您而没有包装。
关于java - Wicket @SpringBean 不创建可序列化代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4544802/