title: Factory method 'redisConnectionFactory' threw exception; Host name must not be null or empty
body: <p>i have implemented redis configuration in my spring boot project using gradle. But when i run the project i'm getting the error saying bean initialization failed.</p>
  
  <p>Following is my config file.</p>
  
  <pre><code>package com.nsdlegov.vsp.config;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.core.env.Environment;
  import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
  import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
  import org.springframework.data.redis.core.RedisTemplate;
  import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
  import org.springframework.data.redis.serializer.StringRedisSerializer;
  
  
  @Configuration
  public class RedisNewConfig {
  
      @Autowired
      private Environment environment;
  
      @Bean
      public LettuceConnectionFactory redisConnectionFactory() {
  
          RedisStandaloneConfiguration serverConfig = new RedisStandaloneConfiguration(environment.getProperty("spring.redis.master"), 6379);
  
          return new LettuceConnectionFactory(serverConfig);
  
      }
  
      @Bean
      public RedisTemplate&lt;String,SchemeMaster&gt; redisTemplateSchemeMaster(){
  
          RedisTemplate&lt;String,SchemeMaster&gt; template= new RedisTemplate&lt;&gt;();
          template.setConnectionFactory(redisConnectionFactory());
          template.setEnableTransactionSupport(true);
          template.setHashKeySerializer(new StringRedisSerializer());  
          template.setHashValueSerializer(new Jackson2JsonRedisSerializer&lt;&gt;(SchemeMaster.class)); 
          template.setKeySerializer(new StringRedisSerializer());
          template.setValueSerializer(new Jackson2JsonRedisSerializer&lt;&gt;(SchemeMaster.class));
  
          template.setEnableTransactionSupport(true);
          return template;
      }
  
      @Bean
      public RedisTemplate&lt;String,PincodeMaster&gt; redisTemplatePincodeMaster() {
          RedisTemplate&lt;String, PincodeMaster&gt; template = new RedisTemplate&lt;&gt;();
          template.setConnectionFactory(redisConnectionFactory());
          template.setEnableTransactionSupport(true);
          template.setHashKeySerializer(new StringRedisSerializer());
          template.setHashValueSerializer(new Jackson2JsonRedisSerializer&lt;&gt;(PincodeMaster.class));
          template.setKeySerializer(new StringRedisSerializer());
          template.setValueSerializer(new Jackson2JsonRedisSerializer&lt;&gt;(PincodeMaster.class));
          return template;
      }
  
      @Bean
      public RedisTemplate&lt;String,IfscMaster&gt; redisTemplateIfscMaster() {
          RedisTemplate&lt;String, IfscMaster&gt; template = new RedisTemplate&lt;&gt;();
          template.setConnectionFactory(redisConnectionFactory());
          template.setEnableTransactionSupport(true);
          template.setHashKeySerializer(new StringRedisSerializer());
          template.setHashValueSerializer(new Jackson2JsonRedisSerializer&lt;&gt;(IfscMaster.class));
          template.setKeySerializer(new StringRedisSerializer());
          template.setValueSerializer(new Jackson2JsonRedisSerializer&lt;&gt;(IfscMaster.class));
          return template;
      }
  }
  </code></pre>
  
  <p>This is my build.gradle file :</p>
  
  <pre><code>buildscript {
      ext {
          springBootVersion = '2.1.1.RELEASE'
      }
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'eclipse'
  apply plugin: 'org.springframework.boot'
  apply plugin: 'io.spring.dependency-management'
  
  
  ext['springCloudVersion'] = 'Finchley.SR1'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile 'io.lettuce:lettuce-core:5.1.1.RELEASE'
      compile 'org.springframework.data:spring-data-redis:2.1.1.RELEASE'
      compile 'org.springframework.boot:spring-boot-starter-web:2.1.2.RELEASE'
      compile 'org.postgresql:postgresql:42.2.5'
      compile 'javax.activation:activation:1.1.1'
      compile 'org.glassfish.jaxb:jaxb-runtime:2.3.0.1'
      compile 'org.springframework.boot:spring-boot-starter-data-jpa:2.1.2.RELEASE'
      compile 'org.hibernate:hibernate-core:5.3.7.Final'
      compile 'org.projectlombok:lombok:1.18.4'
      compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-config', version:'2.0.1.RELEASE'
  }
  
  dependencyManagement {
      imports {
          mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
      }
  }
  
  group = 'com.nsdlegov.vsp'
  version = '0.0.1-SNAPSHOT'
  description = 'vsp-redis-service'
  sourceCompatibility = '1.8'
  
  tasks.withType(JavaCompile) {
      options.encoding = 'UTF-8'
  }
  </code></pre>
  
  <p>Im getting following error:</p>
  
  <pre><code>aused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource [com/nsdlegov/vsp/config/RedisNewConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory]: Factory method 'redisConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Host name must not be null or empty!
      at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$128/46941357.getObject(Unknown Source) ~[na:na]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:273) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1237) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1164) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      ... 22 common frames omitted
  </code></pre>
  
  <p>Firstly the project was in maven. But recently i have converted it to gradle project. In maven it was running fine, But in gradle it is giving me same error.</p>
  
  <p>Please help me and thanks in advance.</p>