• 解决Spring测试出现@EnableAsync annotation metadata was not injected


     Spring测试的时候,出现如下报错,非常奇怪
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.context.annotation.internalAsyncAnnotationProcessor’ defined in class path resource [org/springframework/scheduling/annotation/ProxyAsyncConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor]: Factory method ‘asyncAdvisor’ threw exception; nested exception is java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected

    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor]: Factory method ‘asyncAdvisor’ threw exception; nested exception is java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
    … 43 more
    Caused by: java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected
    at org.springframework.util.Assert.notNull(Assert.java:201)
    at org.springframework.scheduling.annotation.ProxyAsyncConfiguration.asyncAdvisor(ProxyAsyncConfiguration.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    … 44 more

    在这里插入图片描述
    在这里插入图片描述
     后来发现把配置类放在了根路径下,让配置类放在某包路径下就好了
    修改前
    在这里插入图片描述
    修改后
    在这里插入图片描述

  • 相关阅读:
    接口工具HttpRequestUtilObjectToMapUtil
    Java学习多态之向上转型
    场景分类任务可用数据集(部分)
    [源码解析] TensorFlow 分布式之 ParameterServerStrategy V2
    记一次 .NET 某新能源材料检测系统 崩溃分析
    antd vue实现table的分页组件固定位置的效果
    Gitee的注册和代码提交
    晦涩难懂的hashmap源代码-put方法解析
    36.云原生之SpringCloud+k8s实践
    为什么商铺门店一定要做预约软件?
  • 原文地址:https://blog.csdn.net/wasane/article/details/125405126