使用注解方式来配置JavaConfig类,从而代替XML配置文件时运行报错:
AnnotationConfigApplicationContext@1517365b has not been refreshed yet
原因

  1. 需要使用注解类配置文件专用的加载类:
    AnnotationConfigApplicationContext
  2. 检查创建加载类的时候是否传递了目标配置类的class:
    PersonConfig.class

正确写法如下:

@Test
public void test(){AnnotationConfigApplicationContext ac =     // 注意格式和类名new AnnotationConfigApplicationContext(PersonConfig.class);Person person = ac.getBean("person", Person.class);System.out.println(person);
}

AnnotationConfigApplicationContext@xxxx has not been refreshed yet相关推荐

  1. AnnotationConfigApplicationContext ad has not been refreshed yet 错误

    在使用spring框架使用IOC获取bean时有时可能会碰到这个错误 AnnotationConfigApplicationContext  ad has not been refreshed yet ...

  2. AnnotationConfigApplicationContext@51016012 has not been refreshed yet

    在使用Spring获取Person的实例时出现了未刷新的错误 错误代码 AnnotationConfigApplicationContext applicationContext = new Anno ...

  3. org.springframework.context.annotation.AnnotationConfigApplicationContext has not been refreshed yet

    代码如下(为了演示这个报错): AnnotationConfigApplicationContext annotationConfigApplicationContext = new Annotati ...

  4. Spring学习中使用javaConfig进行配置时出现 has not been refreshed yet错误

    Spring学习中使用javaConfig进行配置时出现 has not been refreshed yet错误 java.lang.IllegalStateException: org.sprin ...

  5. 全面了解学习Spring

    Spring的底层的整体了解 1.Bean的声明周期底层原理 2.依赖注入的底层原理 3.初始化底层原理 4.推断构造方法底层原理 5.AOP底层原理 6.Spring事务的底层原理 Spring的大 ...

  6. Spring框架(二) 底层架构核心概念解析-四万字你值得一看

    本篇文章将对Spring底层的一些概念做一些简单的分析 , 也是为了方便后续在阅读源码的时候更加的方便 BeanDefintion BeanDefintion是一个接口 , 它表示一个Bean的定义 ...

  7. AnnotationConfigApplicationContext 报错 has not been refreshed yet

    Caused by: java.lang.IllegalStateException: org.springframework.boot.web.servlet.context.AnnotationC ...

  8. Spring源码深入阅读AnnotationConfigApplicationContext

    一直很好奇代码 AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SimpleBe ...

  9. [WARNING] unable to add QUERY_STRING=XXXX to uwsgi packet, consider increasing buffer size

    1. 问题现象 在用 flask uwsgi api 报文发送 GET 请求时,请求参数的 value 值 "XXX" 太长时,会报下面的错误. [WARNING] unable ...

最新文章

  1. LPC1768基本输入输出GPIO使用
  2. 360浏览器登录_360安全浏览器12下载-360安全浏览器12最新版下载
  3. Hadoop之父Doug Cutting
  4. JavaScript实现在线MD5、SHA、AES、Rabit 、RC4、TripleDES Ripemd160 加密解密工具-toolfk程序员在线工具网...
  5. python pandas读取excel-python pandas 读取文件 写入文件excel
  6. Html中如何让超链接a、图片img居中
  7. 中有冒号 文件路径_用Matlab脚本文件实现Excel文件的合并
  8. 括弧匹配检验(信息学奥赛一本通-T1354)
  9. 渗透测试中说的Shell和Webshll到底是什么
  10. Atitit lucence es solr的各种query 与sql运算符的对比 目录 1.1. 等于运算 TermQuery 1 1.2. 范围运算 1 1.3. 大小运算 1 1.4. Wi
  11. 考研必备数学公式大全(数学二)(线性代数篇)
  12. 标准库函数begin和end的使用
  13. Arduino基础学习
  14. 计算机 打印 速度慢,处理打印机在打印文件时打印速度过慢的原因
  15. 串口通信协议简介—学习笔记
  16. 让最小化安装的CentOS 6.8能够浏览网页
  17. 在各种裁员的“寒冬”,还应该对年终奖有多少期待?!
  18. clock_gettime获取系统时间
  19. 已开源!Flutter 基于分帧渲染的流畅度优化组件 Keframe
  20. 世界各地的土豆代表吃法

热门文章

  1. 使用Ultra Librarian生成Cadence Allegro的PCB封装库和OrCAD Capture CIS的原理图库
  2. 玩玩小程序:使用 WebApi 交互打造原生的微信小程序 - 图灵小书架
  3. 提高组CSP-S初赛模拟试题整理
  4. 山区灭火机器人_帅气!池州市首台消防灭火机器人正式投入基层执勤
  5. 自动批量处理人像照片
  6. Computer Transformation UVA - 1647
  7. C# 中使用TCP连接设置超时问题
  8. 第二个c程序,日语208音练习
  9. 全国各城市经纬度,代码等
  10. bindingx 表达式动画