<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE Configuration Public "-//mybatis.org//dtd Config 3.0//en" "Http://mybatis.org/dtd/mybatis-3-config.dtd" ><Configuration> <Settings> <!--whether to turn on level two cache default to True - <settingname= "cacheenabled"value= "false"/> <!--whether lazy loading - <settingname= "lazyloadingenabled"value= "false" /> </Settings></Configuration>
Even so, when my mappler inside has <cache type= "Com.springbank.dao.support.cache.redis.RedisCache"/> When you query this table, I found MyBatis still checking redis.
# # # Error querying database. Cause:org.springframework.data.redis.RedisConnectionFailureException:Cannot get Jedis connection; Nested exception is java.lang.nullpointerexception### cause: Org.springframework.data.redis.RedisConnectionFailureException:Cannot get Jedis connection; Nested exception is Java.lang.NullPointerExceptionat org.apache.ibatis.exceptions.ExceptionFactory.wrapException ( exceptionfactory.java:30) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList ( defaultsqlsession.java:150) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList ( defaultsqlsession.java:141) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne ( defaultsqlsession.java:77) 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:498) at ORG.MYBATIS.SPRing. Sqlsessiontemplate$sqlsessioninterceptor.invoke (sqlsessiontemplate.java:434) ... morecaused by:org.springframework.data.redis.RedisConnectionFailureException:Cannot get Jedis connection; Nested exception is Java.lang.NullPointerExceptionat Org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector ( jedisconnectionfactory.java:198) at Org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection ( jedisconnectionfactory.java:345)At Com.springbank.dao.support.cache.redis.RedisCache.getObject (rediscache.java:62) at Org.apache.ibatis.cache.decorators.LoggingCache.getObject (loggingcache.java:57) at Org.apache.ibatis.cache.decorators.TransactionalCache.getObject (transactionalcache.java:68) at Org.apache.ibatis.cache.TransactionalCacheManager.getObject (transactionalcachemanager.java:35) at Org.apache.ibatis.executor.CachingExecutor.query (cachingexecutor.java:101) at Org.apache.ibatis.executor.CachingExecutor.query (cachingexecutor.java:83) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:148)... morecaused By:java.lang.NullPointerExceptionat redis.clients.jedis.binaryjedis.<init> (Binaryjedis.java : 101) at redis.clients.jedis.jedis.<init> (jedis.java:78) at Org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector ( jedisconnectionfactory.java:193)
According to the exception stack, see the following code in CACHINGEXECUTOR.JAVA:101
@Override Public<E> list<e>query (mappedstatement MS, Object Parameterobject, Rowbounds rowbounds, Resulthandler Resulthandler, CacheKey key, Bo Undsql boundsql)throwsSQLException {Cache cache=Ms.getcache (); if(Cache! =NULL) {flushcacheifrequired (MS); if(Ms.isusecache () && Resulthandler = =NULL) {Ensurenooutparams (MS, Parameterobject, Boundsql); @SuppressWarnings ("Unchecked") List<E> list = (list<e>) Tcm.getobject (cache, key); if(List = =NULL) {List= delegate.<e>query (MS, Parameterobject, Rowbounds, Resulthandler, Key, Boundsql); Tcm.putobject (cache, key, list); //issue #578 and #116 } returnlist; } } returnDelegate.<e>query (MS, Parameterobject, Rowbounds, Resulthandler, Key, Boundsql); }
So I thought, here's the cache variable if it's null.
Mybatis cannot be turned off by Cacheenabled=false when using Redis as a level two cache