AspectJ与Spring启动

时间:2018-04-28 16:06:40

标签: spring-boot aop aspectj spring-aop

我正在开发一个弹簧启动微服务。我是AspectJ的新手。我正在尝试为日志记录创建一个方面。这是我的方面组件。

@Aspect 
@Component
public class UserAcessAspect {

private static final Logger logger = LoggerFactory.getLogger(UserAcessAspect.class);

@Before("execution(com.profectus.insights.service.impl.InsightsElasticityServiceImpl.*(..))")
public void beforeAdvice(Joinpoint joinPoint, InsightRequest request) {
    logger.info("ASPECTJ------------------->>>>>>>>>>>>");
}

}

我收到以下错误

Caused by: java.lang.IllegalArgumentException: Pointcut is not well-formed:     
expecting 'name pattern' at character position 78
execution(com.profectus.insights.service.impl.InsightsElasticityServiceImpl.*(..))

1 个答案:

答案 0 :(得分:1)

也许你应该阅读

首先学习语法。

您的切入点有什么问题,方法签名没有返回类型。你想写类似

的东西
execution(* com.profectus.insights.service.impl.InsightsElasticityServiceImpl.*(..))