Pointcut is not well-formed: expecting '(' at character position 0

阅读更多

package org.bjrms.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component("logInterceptor")
public class LogInterceptor {
 @Pointcut("execution(public * org.bjrms.dao.Impl.*.*(..))")
 public void MyMethod(){}
 
 @Before("MyMethod")
 public void before(){
  System.out.println("方法执行开始...");
 }
 
 @After("MyMethod")
 public void after(){
  System.out.println("方法执行结束...");
 }
 
 
 public void aroundMethod(ProceedingJoinPoint pjp){
  
 }
}

 

 

 

 

问题:报告异常

 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AddServiceDaoImpl': Injection of resource methods failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplate' defined in class path resource [beans.xml]: Cannot resolve reference to bean 'sf' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sf' defined in class path resource [beans.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [beans.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting '(' at character position 0
MyMethod
^

 

 

解决:MyMethod方法后面添加"()"括号

你可能感兴趣的:(Pointcut is not well-formed: expecting '(' at character position 0)