Must set property 'expression' before attempting to match

Posted zjulanjian

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Must set property 'expression' before attempting to match相关的知识,希望对你有一定的参考价值。

因为这个问题没有直接指向问题的地点, 所以找起来不是很容易. 

但是如果找不到, 这个错就会一直都存在. 

技术图片

原因分析: 在使用切面编程的时候, 没有把切入点配置全面

解决方法: 在before, after, after-returning的注解后面都加上pointCut()方法

@Aspect
@Component("tranManager")
public class TransactionManager {

    @Autowired
    @Qualifier("session")
    private Session session = null;

    private Transaction transaction = null;

    @Pointcut("execution(* com.bj186.crm.service.impl.*.*(..))")
    public void pointCut() {

    }

    @Before("pointCut()") //这里添加切入点
    public void begin() {
        transaction = session.beginTransaction();
    }

    @AfterReturning("pointCut()") //这里也必须添加
    public void commit() {
        transaction.commit();
    }

    @AfterThrowing("pointCut()") //不添加切入点编译不会报错, 但是运行时会报错
    public void rollback() {
        transaction.rollback();
    }
}

 

以上是关于Must set property 'expression' before attempting to match的主要内容,如果未能解决你的问题,请参考以下文章

The content of element type "configuration" must match "(properties?,settings?,typeAl

转The content of element type "configuration" must match "(properties?,settings?,typ

The path to the driver executable must be set by the webdriver.gecko.driver system property;

The path to the driver executable must be set by the webdriver.gecko.driver system property

Cannot find current proxy: Set 'exposeProxy' property on Advised to 'true' to make i

You must configure either the server or JDBC driver (via the ‘serverTimezone‘ configuration property