草庐IT

spring-boot - Spring boot + Redis - 生成一个奇怪的 key

我正在使用Spring-boot+Redis将我的数据存储在缓存中。我的Controller有这样的配置:publicclassCacheController{@GetMapping("/{key}")@Cacheable(value="myCacheValue",keyGenerator="customKeyGenerator")publicStringgetByKey(@PathVariable("key")Stringkey){returnkey+System.currentTimeMillis();}}我的自定义key生成器是:publicclassCustomKeyGener

spring-boot - 我不知道为什么会这样。 jedis 创建名称为 'jedisConnectionFactory' 的 bean 时出错

运行应用程序后检测到错误。我找不到任何问题,我需要帮助。包结构由配置和Controller组成。spring-boot-starter-data-redisredis.clientsjedis3.0.1packagecom.arthur.springbootredis.config;importorg.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;importorg.springframework.context.annotation.Bean;importorg.springframewor

java - Spring Boot 项目的 Redis max-active 配置值

我已经为Springboot应用程序实现了redis。我应该为application.properties中的以下配置输入什么值?#spring.redis.pool.max-active=8文档中默认为8。然后,我将其设置为1并使用多次调用来测试redis存储库。虽然我预计会出现错误提示,redis连接不可用,但我没有收到任何错误。我在这里错过了什么?更新问题:正如下面提到的mp911de,我在我的restController方法中添加了@Transactional并让线程等待10秒。WhenusingSpringDataRediswithenabled@Transactional,

在 header 中找不到 Spring Boot 安全性 x-auth-token

我有一个springboot应用程序,其REST服务受springsecurity保护。Redis用于存储session。我已经在Glassfish4.1.2中部署了该应用程序。尝试使用基本身份验证登录时,x-auth-token不会在响应header中返回。可能是什么问题?下面是我的配置类:应用安全配置@Configuration@EnableWebSecuritypublicclassApplicationSecurityConfigextendsWebSecurityConfigurerAdapter{@AutowiredprivateCustomAuthenticationPr

spring-boot - spring 数据 redis 循环引用

您好,我是springdataredis的新手,遇到以下循环引用问题:假设我在Java中有如下代码:classPerson{@IdprivateStringId;privateStringname;privateintage;@ReferenceprivatePersonfather;@ReferenceprivateListchildren;...settersandgetters}我的目标是,当给出一个人的名字时,我想得到一个包含他父亲信息和child信息的人对象,我所说的信息是指人对象。我看到的问题是这里有一个循环引用,因为给出名字的人包含在他父亲的child名单中,所以它实际上

使用 Spring Boot 进行缓存 - Redis 键名中的 ~keys 是什么?

当我尝试从redis-cli显示key时,从我的应用程序方法生成的key生成了cachename~keys,~keys是什么?我使用带有自定义键的SpringBoot@Cacheable注释,它显示了这些。我试过谷歌搜索,但没有任何答案。它是key的通配符吗?我怎样才能显示这一切??谢谢 最佳答案 您需要在CacheManagerbean中将参数“usePrefix”设置为true。这将在您的key中添加cacheName。...true... 关于使用SpringBoot进行缓存-Re

session - Spring boot 2.0/Tomcat 8.5 - 日志文件中的 session 属性

我想记录发出每个请求的用户名。成功登录后,我使用此方法将用户名设置为session变量-用户名。@OverridepublicvoidonAuthenticationSuccess(HttpServletRequestrequest,HttpServletResponseresponse,Authenticationauthentication)throwsIOException,ServletException{Stringusername=merchandiserRepository.findByUsername(authentication.getName()).getUsern

java - 没有 Sentinel 连接,Spring Boot 和 Spring Data Redis 无法启动

这是我的第一个问题,如果我的问题表达方式还需要改进,请原谅我我目前正在开发一个SpringBootWeb应用程序,它使用Redis作为缓存来防止对外部API的过度调用。从这个意义上说,Spring实际上很好,但不是必需的。项目结构如下1.)包含DAO类的持久化模块编译spring-data-redis项目并使用带有@Autowired注解的RedisTemplate示例RedisDao类(由于私有(private)代码原因,我没有使用确切的实现):@AutowiredprivateRedisTemplateredisTemplatepublicAuthInfoDtocreateAuth

docker - Spring Boot Redis 在使用 Redis 时获取连接被拒绝的异常

我有一个小型应用程序,我使用Redis进行缓存和SpringBoot。应用程序在本地成功运行,但当我尝试对其进行dockerize时,出现连接拒绝异常。这是我的docker-compose.yml文件:version:'3.5'services:my-application:image:my-application:latestcontainer_name:my-applicationports:-8080:8080hostname:my-applicationredis:image:rediscommand:["redis-server","--protected-mode","no

spring-boot - 无法从 Spring Boot 连接到 Dockerized Redis

我有一个在Windows10机器上运行的springbootrest服务,我有一个在docker容器上运行的Redis。现在,我想让我的SpringBoot连接到redis容器,但是,它总是给我以下错误:java.net.UnknownHostException:redis我的application.properties,包含以下内容:#SetRedisserverandJedissettingsspring.redis.host=redisspring.redis.port=6379spring.redis.password=test123spring.jedis.connectio