You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot AOP项目报Pointcut is not well-formed异常无法创建切入点

错误触发原因

抛出java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting >>>'(' at character position 0的核心原因是通知注解引用命名切入点的语法错误。
Spring AOP中定义的命名切入点本质是一个空方法,在@Before/@After等通知注解中引用该切入点时,必须遵循方法名()的写法,不能直接写方法名。当前代码中@Before("p1")传入的字符串p1会被框架直接当作原生切入点表达式解析,表达式首字符不符合语法要求(切入点指示符后必须跟左括号),因此直接抛出格式错误异常,和包扫描、依赖导入、包路径配置无关。

修复方案

将@Before注解的属性值从"p1"修改为"p1()"即可,修正后的完整切面代码如下:

@Aspect
@Component
public class TxService {

    @Pointcut("execution(public void com.boot.aop.dao.EmployeeDao.saveEmployee())")
    public void p1() {
    
    }
        
    @Before("p1()")
    public void beginTx() {
        System.out.println("Transaction is started");
    }
}
补充说明
  • 同切面内引用自定义命名切入点,直接写方法名()即可正常识别
  • 如果需要在其他切面类中引用该切入点,需要写全类路径+方法名+括号,格式为全限定类名.方法名()

内容的提问来源于stack exchange,提问作者Jaydeep

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.26 16:57:23