spring boot 配置AOP无反应
springboot是2.1版本
这是我的切面类
@Aspect
@Component
public class SignAop {
@Autowired
private SignService signService;
@Before(value = "execution(* com.pyx.seller.controller.*.*(..)) && args(authId,sign,text,..)")
public void verify(String authId,String sign,SignText text){
String publicKey = signService.getPublicKey(authId);
Assert.isTrue(RSAUtil.verify(text.toText(),sign,publicKey),"验签失败");
}
}
这是我的controller类
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {
@Autowired
private OrderService orderService;
@RequestMapping(value = "/apply", method = RequestMethod.POST)
public Order apply(@RequestHeader String authId,@RequestHeader String sign, @RequestBody OrderParam param) {
log.info("申购请求:{}", param);
Order order = new Order();
BeanUtils.copyProperties(param,order);
order = orderService.apply(order);
log.info("申购结果:{}", order);
return order;
}
}
这是我的程序入口
@SpringBootApplication
@EntityScan("com.pyx.entity")
@EnableSwagger2
@EnableCaching
public class SellerApp {
public static void main(String[] args) {
SpringApplication.run(SellerApp.class);
}
}
我在切面下端点发现无法执行切面,更改过 @Before的value值也无效
verify 和 apply 参数一样才行吧, 至少看你的 args 是这个要求的