如何在JHipster中配置Redis密码?参考官方文档未找到方案
在JHipster中配置Redis密码的解决方案
别担心,我帮你梳理下JHipster里配置Redis密码的正确方式——其实你只需要对现有配置做一点调整就能实现,有两种常用的方案可选:
方案1:在Redis连接URL中直接包含密码
你可以直接在server字段的URL里添加密码信息,格式如下:
http: cache: # Used by the CachingHttpHeadersFilter timeToLiveInDays: 1461 cache: # Cache configuration redis: # Redis configuration expiration: 3600 # By default objects stay 1 hour (in seconds) in the cache server: redis://:your_redis_password@localhost:6379
如果你的Redis还设置了用户名,可以用这种格式:redis://your_username:your_redis_password@localhost:6379
方案2:拆分配置项单独设置密码
如果你更喜欢结构化的配置方式,也可以把Redis连接信息拆分成独立字段,可读性更强:
http: cache: # Used by the CachingHttpHeadersFilter timeToLiveInDays: 1461 cache: # Cache configuration redis: # Redis configuration expiration: 3600 # By default objects stay 1 hour (in seconds) in the cache host: localhost port: 6379 password: your_redis_password
这两种配置方式都能让JHipster正确连接到带密码验证的Redis服务,你可以根据自己的习惯选择其中一种。
内容的提问来源于stack exchange,提问作者TonyLuo
相关产品推荐
相关产品推荐

