"target" and "not @annotation" combination not works as expected, but "target" and "@annotation" combination works fine.

    // works as expected
    @Around("execution(public * *(..)) and target(repository) and @annotation(org.springframework.transaction.annotation.Transactional)")
    public Object interceptPositive(ProceedingJoinPoint pjp, Repository repository) throws Throwable {
        Method method = ((MethodSignature) pjp.getSignature()).getMethod();
        if (!method.isAnnotationPresent(Transactional.class))
            throw new RuntimeException("annotation should present here");
        return pjp.proceed();
    }

    // not works as expected
    @Around("execution(public * *(..)) and target(repository) and not @annotation(org.springframework.transaction.annotation.Transactional)")
    public Object interceptNegative(ProceedingJoinPoint pjp, Repository repository) throws Throwable {
        Method method = ((MethodSignature) pjp.getSignature()).getMethod();
        if (method.isAnnotationPresent(Transactional.class))
            throw new RuntimeException("annotation should not present here");
        return pjp.proceed();
    }

test-pointcut.zip is a test project

Comment From: sbrannen

@quaff, have you tried the following?

@Around("execution(public * *(..)) and target(repository) and !@annotation(org.springframework.transaction.annotation.Transactional)")

Comment From: quaff

@quaff, have you tried the following?

java @Around("execution(public * *(..)) and target(repository) and !@annotation(org.springframework.transaction.annotation.Transactional)")

Yes, same result.

Comment From: quaff

Still not fixed in v6.0.6.

Comment From: sbrannen

Still not fixed in v6.0.6.

Indeed.

I've just assigned to this to the 6.1.x backlog, so that somebody from the team can pick it up.

Comment From: nakulmitra

@sbrannen what if I used && in place of and, will it work?

@Around("execution(public * *(..)) && target(repository) && !@annotation(org.springframework.transaction.annotation.Transactional)")

Comment From: quaff

@sbrannen what if I used && in place of and, will it work?

java @Around("execution(public * *(..)) && target(repository) && !@annotation(org.springframework.transaction.annotation.Transactional)")

I don't think it will works, && is simply substitution of and.

Comment From: jhoeller

Superseded by PR #30534.