markbug 2015-12-21 00:58 采纳率: 77.8%
浏览 1481
已采纳

急!!!!!!spring日志管理问题--不进advice

这是我applicationCotext.xml中的配置文件



aop:config






/aop:aspect

/aop:config


这是我的advices类


public class Advisor {
static Logger log = Logger.getLogger(Advisor.class);
public String information;
/**
*
*/
public Advisor() {
// TODO Auto-generated constructor stub
log.info("进入");
}

 public void before(JoinPoint joinpoint){  
     information = "通知:"+joinpoint.getClass().getName()+"类的"+joinpoint.getClass().getMethods()+"开始执行";
     log.info(information);
 }  
 public void after(JoinPoint joinpoint){
    information = "通知:"+joinpoint.getClass().getName()+"类的"+joinpoint.getClass().getMethods()+"执行完毕";
    log.info(information);
 }  
 public void exception(JoinPoint joinpoint){
    information = "通知:"+joinpoint.getClass().getName()+"类的"+joinpoint.getClass().getMethods()+"出现异常";
    log.info(information);
 }

}


  • 写回答

2条回答 默认 最新

  • markbug 2015-12-21 00:59
    关注
    <!--将日志类注入到bean中。-->  
    <bean id="advices" class="com.sunyard.advice.Advisor"></bean>
    <aop:config>  
                <aop:aspect id="log" ref="advices"> 
                   <aop:pointcut id="pointcut" expression="execution(* com.sunyard.cpjbxxShow.action.*.*(..))"/> 
                   <aop:before pointcut-ref="pointcut" method="before"/> 
                   <aop:after pointcut-ref="pointcut" method="after"/> 
                   <aop:after-throwing pointcut-ref="pointcut" method="exception"/>
                </aop:aspect>  
     </aop:config>   
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码