org.springframework.context.support.AbstractApplicationContext refresh

org.springframework.context.support.AbstractApplicationContext refresh

spring 项目启动报错:
4月 03, 2021 12:48:48 下午 org.springframework.context.support.AbstractApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘serviceImp’ defined in file [C:\Users\19165\IdeaProjects\spring_course\04_AOP_demo\target\classes\com\hrz\ba01\ServiceImpl.class]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: com.hrz.ba01 [Xlint:invalidAbsoluteTypeName]

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘serviceImp’ defined in file [C:\Users\19165\IdeaProjects\spring_course\04_AOP_demo\target\classes\com\hrz\ba01\ServiceImpl.class]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: com.hrz.ba01 [Xlint:invalidAbsoluteTypeName]

报错原因 : 切入点表达式错误

源代码

@Aspect
@Component(value = "myAspect")
public class AspectJ_Demo {

@Before(value = "execution(* com.hrz.ba01.do*(..))")
    public void printTime(){
        System.out.println(new Date());
    }
}

切入点表达式应改为:execution(* com.hrz.ba01.*.do*(..))

附录:切入点表达式
AspectJ 定义了专门的表达式用于指定切入点。表达式的原型是:

execution(modifiers-pattern? ret-type-pattern 
declaring-type-pattern?name-pattern(param-pattern)
 throws-pattern?)

解释:
modifiers-pattern] 访问权限类型
ret-type-pattern 返回值类型
declaring-type-pattern 包名类名
name-pattern(param-pattern) 方法名(参数类型和参数个数)
throws-pattern 抛出异常类型
?表示可选的部分

切入点表达式要匹配的对象就是目标方法的方法名。所以,execution 表达式中明显就是方法的签名。注意,表达式中黑色文字表示可省略部分,各部分间用空格分开。在其中可以使用以下符号:
符号意义
*0至多个任意字符
. .用在方法参数中 表示任意多个参数 ;用在包名后,表示当前包及其子包路径
+用在类名后,表示当前类及其子类;用在接口后,表示当前接口及其实现类
  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值