在使用spring-data-redis时使用junit测试报错:
  java.lang.IllegalArgumentException: template not initialized; call afterPropertiesSet() before using

通过跟踪代码发现是这一句出了问题:

Assert.isTrue(this.initialized, "template not initialized; call afterPropertiesSet() before using it");

而initialized是在public void afterPropertiesSet() 中被赋值为true的。

解决方式:
不能直接在代码中用new来直接实例化,必须得用SpingBean的实例化方式来!

java.lang.IllegalArgumentException: template not initialized; call afterPropertiesSet() before using的更多相关文章

  1. java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required

    java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required 严重: Exceptio ...

  2. SSH框架环境搭建问题:java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required

    SSH框架启动tomcate时出错 严重: Exception sending context initialized event to listener instance of class org. ...

  3. 解决java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext这个问题

    今天在运行别人的SSH项目时,遇到了这个问题 严重: Exception sending context initialized event to listener instance of class ...

  4. IDEA报错: Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}"

    运行审核流模块: 在ActivitiServiceApplication模块日志报错: Error starting ApplicationContext. To display the auto-c ...

  5. hive启动时报错 java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D at org.apache.hadoop.fs.Path.initialize

    错误提示信息如下 错误信息如下 [root@node1 bin]# ./hive Logging initialized -bin/lib/hive-common-.jar!/hive-log4j.p ...

  6. Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required [ IDEA mybatis项目报错 ]

    今天笔者用Springboot框架整合Mybatis做一个小小的项目: 代码写完,在运行项目时,IDEA给我报了3处错误: org.springframework.beans.factory.Unsa ...

  7. Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'jdbc.username' in string value "${jdbc.username}"

    1.启动dubbo的引用dubbo服务时候报下面这个错误,这是由于去找dubbo的发布服务未找到报的错误,所以先启动dubbo的发布服务即可. [INFO] Scanning for projects ...

  8. 使用 Jenkins 打包成功后 运行 出现 Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    linux 运行时 错误日志 Error starting ApplicationContext. To display the conditions report re-run your appli ...

  9. springcloud中config启动时候报错Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'config.info' in value "${config.info}"

    -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jm ...

随机推荐

  1. input 边框颜色

    border 的属性 有三个 border:5px solid red; 如果上述值缺少一个没有关系,例如border:#FF0000;是允许的. 分别对应:border-width, border- ...

  2. ubuntu kylin 16.04系统的基本安装

    系统版本:ubuntu kylin 16.04 硬件状况:500G HDD+120G SSD 已安装操作系统:WIN 10专业版(craked) ——WIN 10系统是装在SSD的第一个盘符内的.以前 ...

  3. 前端基础 JavaScript~~~ 数据处理 奇技淫巧!!!!!!

    常用的JS数据处理手段      2016-09-21          17:40:07 1.   number类型  数组中取出里面的最大/最小值: // 数组中取出 最小值 [数值] var n ...

  4. AJAX原理及应用

    Ajax技术的核心是XMLHttpRequest对象(简称XHR),可以通过使用XMLHttpRequest对象获取到服务器的数据,然后再通过DOM将数据插入到页面中呈现.也就是javascript可 ...

  5. eclipse中的窗口切换快捷键

    Ctrl+Shift+F6 很简单,如果以后改用IDEA的话就没用了,但这个窗口切换确实很复杂,看起来也操作比较快.

  6. Apache Commons 系列简介 之 Pool

    一.概述 Apache Commons Pool库提供了一整套用于实现对象池化的API,以及若干种各具特色的对象池实现.2.0版本,并非是对1.x的简单升级,而是一个完全重写的对象池的实现,显著的提升 ...

  7. HTML中的属性、段落、标题、换行等

    HTML的属性html标签的属性总是以名称/值(name=“value”)的方式出现:属性总是在html元素的开始标签中规定: 1.html链接由<a>标签定义,url在href中指定:& ...

  8. 如何用BarTender批量打印标签

    关于使用BarTender条码打印软件打印标签,很多小伙伴最关心的问题之一,莫过于如何实现BarTender批量打印标签.为了提高日常标签打印速度,为了方便快捷,也为了减少出错率,快来跟小编学习学习吧 ...

  9. Python range() xrange()

    range 前面小节已经说明了,range([start,] stop[, step]),根据start与stop指定的范围以及step设定的步长,生成一个序列. xrange用法与 range 完全 ...

  10. U盘容量变小的处理方式

    我就说一下win7下的步骤吧,xp应该差不多,管理员身份运行命令行(快捷键win+R), diskpart回车 list disk回车 看看你的u盘是哪一个,选择他(select disk X回车) ...