cargoj 2012-08-22 14:36 采纳率: 100%
浏览 278
已采纳

通过CGLIB实现AOP动态切换数据源,代理失败

[code="java"]
public class DatasourceBeforeAdvice implements MethodBeforeAdvice{

@Override
public void before(Method method, Object[] args, Object target)
        throws Throwable {
    // TODO Auto-generated method stub
    String serverCode = (String)args[0];
    for(CustomerType ct : CustomerType.values()){
        if(ct.toString().equals(serverCode)){
            CustomerContextHolder.setCustomerType(ct);
            break;
        }
    }
}

}
[/code]
[code="java"]






dsBeforeAdvice



[/code]
结果没有进入advice,代理失败,请教一下原因。

  • 写回答

1条回答 默认 最新

  • jinnianshilongnian 2012-08-22 14:48
    关注

    没有指定target
    void setTarget(Object target)
    Set the given object as target.

    1、targetClass:Set a target class to be proxied, indicating that the proxy should be castable to the given class. (指定代理的类的类型 会把目标对象转成该类型进行代理)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献