Hi, When trying to import a redis URI through the property values, the URI can not be imported when it is in the format:
redis://:password@host:port
result is:
://:@127.0.0.1:6371
But imports fine when the format:
redis://username:password@host:port
result is:
redis://h:password@127.0.0.1:6371
To test this I am just logging the value of the String:
@Configuration
@EnableRedisHttpSession(maxInactiveIntervalInSeconds=604800)
public class SessionConfig {
@Value("${REDIS_URL}")
private String redisStr2;
private static final Logger log = LoggerFactory.getLogger(SessionConfig.class);
@Autowired
private Environment env;
@Bean
public JedisConnectionFactory connectionFactory() throws URISyntaxException {
log.info(env.getProperty("REDIS_URL"));
log.info(redisStr2);
URI redisUri = null;
if (redisStr.contains("://h:")) {
redisUri = new URI(redisStr2);
} else if (redisStr.contains("://:")){
String newStr = redisStr2.replace("://:", "://h:");
log.info(newStr);
redisUri = new URI(newStr );
}
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(redisUri.getHost(), redisUri.getPort());
redisStandaloneConfiguration.setPassword(RedisPassword.of(redisUri.getUserInfo().split(":",2)[1]));
return new JedisConnectionFactory(redisStandaloneConfiguration);
}
}
Using:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.15.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>