切入点表达式“abc(inString)"包含不受支持的切入点原语“调用" [英] Pointcut expression 'abc(inString)' contains unsupported pointcut primitive 'call'

查看:36
本文介绍了切入点表达式“abc(inString)"包含不受支持的切入点原语“调用"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 spring-aop 概念的新手.

I am new to spring-aop concepts.

我在编译过程中遇到此错误.

I am getting this error during compilation.

org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException:切入点表达式abc(inString)"包含不受支持的切入点原始'调用'

org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException: Pointcut expression 'abc(inString)' contains unsupported pointcut primitive 'call'

我的观点是,

@Aspect
@Component
public class BeforeAdvice {

      @Pointcut(value="call(@com.app.test.EncryptDemo * *(String)) && args(inString) && !within(com.app.test.BeforeAdvice)",argNames="inString")
      public void abc(String inString) {};

      @Around(value = "abc(inString)",argNames="inString")
      public Object ourAroundAdvice(ProceedingJoinPoint pjp, String inString) throws Throwable {

          System.out.println("in around");
          return null;
      }
  }

我的自定义注解

@Documented
@Target({ ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface EncryptDemo {

}

我的实体

@Entity
@Table(name="customer")
@JsonIgnoreProperties(ignoreUnknown = true)
public class Customer {

    @Id
    @GeneratedValue
    private Long id;

    private String somethingPublic;

    private String somethingPrivate;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getSomethingPublic() {
        return somethingPublic;
    }

    public void setSomethingPublic(String somethingPublic) {
        this.somethingPublic = somethingPublic;
    }

    public String getSomethingPrivate() {
        return somethingPrivate;
    }

    @EncryptDemo
    public void setSomethingPrivate(String somethingPrivate) {
        this.somethingPrivate = somethingPrivate;
    }
}

我已将此依赖项添加到 pom.

I have added this dependency to pom.

spring-boot-starter-aop

spring-boot-starter-aop

方面

aspectjweaver

aspectjweaver

我找到了一个解决方案,但我不明白他们想说什么.

I found one solution but I am not understanding what they are trying to say.

简单 AOP 示例上的 UnsupportedPointcutPrimitiveException

请指导我解决这个问题.任何帮助将不胜感激.

Please guide me towards this. Any help will be appreciate.

谢谢.

推荐答案

Spring 使用(默认)基于代理的 AOP,因此对连接点表达式的支持有限.不支持的 call 连接点只有 execution 连接点是.支持的连接点表达式记录在 这里.

Spring uses (by default) proxy based AOP and as such has only limited support for joinpoint expression. The call join point that isn't supported only the execution join point is. The supported join point expressions are documenten here.

接下来,您正在尝试将 AOP 应用于非 Spring 托管的 bean,这也不适用于基于代理的解决方案.

Next to that you are trying to apply AOP to a non Spring managed bean this will also not work with a proxy based solution.

对于这两种情况,您都需要使用 加载 或编译时编织以使其工作.

For both situations you need to use either load or compile time weaving to make it work.

这篇关于切入点表达式“abc(inString)"包含不受支持的切入点原语“调用"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆