菜鸟求解 spring aop

fhhffchffy 2010-12-12 08:37:49
<!-- aop配置 -->
<aop:config>
<!-- 配置日志切面 -->
<aop:aspect id="logaop" ref="logAspectJ">
<!-- 定义切入点正则表达式 userManager类下的所有方法-->
<aop:pointcut id="logpointcut" expression="execution(* com.fhh.service.UserManager.*(..))"/>
<aop:before pointcut-ref="logpointcut" method="myBeforeAdvice"/>
<aop:after-returning pointcut-ref="logpointcut" method="myAfterReturningAdvice"/>
<aop:after-throwing pointcut-ref="logpointcut" method="myAfterThrowAdvice" throwing="e"/>
<aop:after pointcut-ref="logpointcut" method="myAfterAdvice"/>
<aop:around pointcut-ref="logpointcut" method="myAroundAdvice"/>
</aop:aspect>
</aop:config>

请问一下这样的配置为什么在执行com.fhh.service包下的UserManager类的任何方法时没有没有执行那些通知啊。
不好意思啊,没有分了。
...全文
86 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
fhhffchffy 2010-12-19
  • 打赏
  • 举报
回复
tubage408和qihigh都说得很对,非常感谢!
qihigh 2010-12-16
  • 打赏
  • 举报
回复
在log4j的配置中加上这句,就能看见你的info了
log4j.rootLogger=INFO, stdout
tubage408 2010-12-15
  • 打赏
  • 举报
回复
那你看看你log4j的配置,是输出到文件,还是console
fhhffchffy 2010-12-15
  • 打赏
  • 举报
回复
真是悲具呀。其实已经是织入成功了。不过那个方法没有信息输出,不知道为什么。

//取得日志记录器
public Logger logger1=Logger.getLogger(LogAspectJ.class);
public void myBeforeAdvice1(JoinPoint joinpoint){
String classAndMethod=joinpoint.getTarget().getClass().getName()+"类的"+joinpoint.getSignature().getName();
logger1.info("前置通知:"+classAndMethod+"方法开始执行!");

System.out.println("ni hao!");
}

只是输出了 ni hao!
tubage408 2010-12-14
  • 打赏
  • 举报
回复
没有织入通知?也没异常啥的?
fhhffchffy 2010-12-14
  • 打赏
  • 举报
回复
这个还要用什么啊。
帮举个例子怎么用啊。
Jlins 2010-12-13
  • 打赏
  • 举报
回复
logaop 在使用吗?

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧