代码没有起作用呢, 那个注解切面





import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 自定义权限注解:
*
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface AdminOnly {
}import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
/**
*切面demo
*/
@Slf4j
@Aspect
@Component
public class authAspect {
@Pointcut("@annotation(com.xiejiadao.girl.annotations.AdminOnly)")
public void adminOnly() {
}
@Before("adminOnly()")
public void before() {
log.info("执行aop,before方法。");
}
}import com.xiejiadao.girl.annotations.AdminOnly;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 测试并发
* @author: xyf
* @date: 2019/7/14 17:41
*/
@RestController
@Slf4j
public class TestController {
@AdminOnly
@GetMapping("/test")
public String test() {
return "test";
}
}
我的spring boot版本是:
2.1.4.RELEASE
pom.xml我也没特别配置。你可以看下我每个类上import的和你的有不同的吗