问题:IllegalArgumentException: error wildcard type pattern not allowed, must use type name****

来源:7-2 Advice定义及实例

阳光洒在路上就不怕心碎f

2017-03-11 18:44

执行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.");
	}
}


写回答 关注

2回答

  • 阳光洒在路上就不怕心碎f
    2017-03-11 19:04:00

    问题解决了:这里写错了  @Pointcut("with(com.imooc.aop.aspectj.biz.*)") 

    改成@Pointcut("within(com.imooc.aop.aspectj.biz.*)")

    就ok了。


  • 阳光洒在路上就不怕心碎f
    2017-03-11 18:52:03

    error wildcard type pattern not allowed, must use type name 这句话的意思是通配符类型不允许,要使用类型的名称,是什么意思呢?


Spring入门篇

为您带来IOC和AOP的基本概念及用法,为后续高级课程学习打下基础

268787 学习 · 1026 问题

查看课程

相似问题