【问题标题】:Troubleshooting session-scoped bean with aop:scoped-proxy使用 aop:scoped-proxy 对会话范围 bean 进行故障排除
【发布时间】:2011-07-23 20:34:58
【问题描述】:

在我的 Spring 3 项目中,我有以下 bean 定义

<bean name="account" class="sample.model.Account" scope="session">
    <aop:scoped-proxy proxy-target-class="true" />
</bean>

CGLib 2.2 位于类路径中,因此根据 Spring 文档,帐户 bean 的范围应为客户端的 http 会话。

我在用户登录时填充帐户 bean,如果没有用户登录,则帐户 bean 为空。但是,当同时使用两个浏览器来模拟两个不同的 http 会话并在一个浏览器上登录时,另一个浏览器也已登录。我将此行为解释为帐户 bean 未限定为会话

对此有什么建议吗?有没有办法检查是否已创建 CGLib 代理?当我调试应用程序并在运行时检查注入的帐户 bean 的类型时,它的 sample.model.Account。我不确定这是否最终意味着没有 CGLib 代理 cass。

【问题讨论】:

    标签: spring spring-mvc jakarta-ee aop spring-aop


    【解决方案1】:

    只需在构造函数中设置一个断点,它应该在每个会话中命中一次

    【讨论】:

      猜你喜欢
      • 2014-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-02
      • 2011-02-07
      • 2013-11-20
      相关资源
      最近更新 更多