执行test时,使用@Before("execution(* com.imooc.aop.aspectj.biz.*Biz.*(..))")可以成功测试,配置@Before("pointcut()"),出现IllegalArgumentException: error wildcard type pattern not allowed, must use type name at***错误,求解答
代码如下:
//MoocAspect类
@Component
@Aspect
public class MoocAspect
{
// 定义两个切入点
// 匹配方法执行的切入点
@Pointcut("execution(* com.imooc.aop.aspectj.biz.*Biz.*(..))")
public void pointcut()
{
};
// 限定匹配特定类型的连接点
@Pointcut("with(com.imooc.aop.aspectj.biz.*)")
public void biaPointcut()
{
};
// before advice
// 方法一
// @Before("execution(* com.imooc.aop.aspectj.biz.*Biz.*(..))")
@Before("pointcut()")
public void before()
{
System.out.println("Before.");
}
}问题解决了:这里写错了 @Pointcut("with(com.imooc.aop.aspectj.biz.*)")
改成@Pointcut("within(com.imooc.aop.aspectj.biz.*)")
就ok了。
error wildcard type pattern not allowed, must use type name 这句话的意思是通配符类型不允许,要使用类型的名称,是什么意思呢?