java.lang.IllegalStateException:无法解析'Builder [public com.test.demo.model.User com.test.demo.service.UserSerImpl.selectUser(java.lang.Integer)] caches = [ ] | key ='#uId'| keyGenerator =''| | cacheManager =''| | cacheResolver =''|条件=''|除非=''|使用解析器'org.springframework.cache.interceptor.SimpleCacheResolver@39fa48c0'sync ='false'。每次缓存操作至少应提供一个缓存。 在org.springframework.cache.interceptor.CacheAspectSupport.getCaches(CacheAspectSupport.java:227)〜[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.cache.interceptor.CacheAspectSupport $ CacheOperationContext。(CacheAspectSupport.java:669)〜[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.cache.interceptor.CacheAspectSupport.getOperationContext(CacheAspectSupport.java:237)〜[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.cache.interceptor.CacheAspectSupport $ CacheOperationContexts。(CacheAspectSupport.java:570)〜[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:317)〜[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)〜[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)〜[spring-aop-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.aop.framework.CglibAopProxy $ DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)〜[spring-aop-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在com.test.demo.service.UserSerImpl $$ EnhancerBySpringCGLIB $$ 576dbac0.selectUser()〜[main /:na] 在com.test.demo.controller.UserCon.selectUser(UserCon.java:28)〜[main /:na] 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处〜[na:1.8.0_144] 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)〜[na:1.8.0_144] 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)〜[na:1.8.0_144] 在java.lang.reflect.Method.invoke(Method.java:498)〜[na:1.8.0_144] 在org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)〜[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)〜[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)〜[spring-webmvc-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877)〜[spring-webmvc-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783)〜[spring-webmvc-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)〜[spring-webmvc-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)〜[spring-webmvc-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)〜[spring-webmvc-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)〜[spring-webmvc-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:877)〜[spring-webmvc-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在javax.servlet.http.HttpServlet.service(HttpServlet.java:661)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)〜[spring-webmvc-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在javax.servlet.http.HttpServlet.service(HttpServlet.java:742)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)〜[tomcat-embed-websocket-8.5.31.jar:8.5.31] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)〜[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)〜[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)〜[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:147)〜[spring-session-core-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:81)〜[spring-session-core-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)〜[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)〜[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)上[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:790)[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1468)[tomcat-embed-core-8.5.31.jar:8.5.31] 在org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)上[tomcat-embed-core-8.5.31.jar:8.5.31] 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[na:1.8.0_144]
package com.test.demo.redis;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
@Configuration
@EnableCaching
@EnableRedisHttpSession
public class RedisConfig extends CachingConfigurerSupport {
/**
* @description 自定义的缓存key的生成策略 若想使用这个key
* 只需要讲注解上keyGenerator的值设置为keyGenerator即可</br>
* @return 自定义策略生成的key
*/
// @Bean
// public KeyGenerator keyGenerator() {
// return new KeyGenerator() {
// @Override
// public Object generate(Object target, Method method, Object... params) {
// StringBuffer sb = new StringBuffer();
// sb.append(target.getClass().getName());
// sb.append(method.getName());
// for (Object obj : params) {
// sb.append(obj.toString());
// }
// return sb.toString();
// }
// };
// }
// 缓存管理器
@Bean
public CacheManager cacheManager(RedisConnectionFactory factory) {
RedisCacheManager cacheManager = RedisCacheManager.create(factory);
return cacheManager;
}
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
redisTemplate.setConnectionFactory(factory);
return redisTemplate;
}
@Bean
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) {
StringRedisTemplate stringRedisTemplate = new StringRedisTemplate();
stringRedisTemplate.setConnectionFactory(factory);
return stringRedisTemplate;
}
}
java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)[na:1.8.0_144] 在org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)[tomcat-embed-core-8.5.31.jar:8.5.31] 在java.lang.Thread.run(Thread.java:748)[na:1.8.0_144]