title: Spring Boot Redis configuration not working
body: <p>I am developing a Spring Boot [web] REST-style application with a <code>ServletInitializer</code> (since it needs to be deployed to an existing Tomcat server). It has a <code>@RestController</code> with a method that, when invoked, needs to write to a Redis <code>pub-sub channel</code>. I have the Redis server running on localhost (default port, no password). The relevant part of the POM file has the required starter dependency:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-data-redis&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>When I deploy the WAR and hit the endpoint <code>http://localhost:8080/springBootApp/health</code>, I get this response:</p>
  
  <pre><code>{
    "status": "DOWN",
    "diskSpace": {
      "status": "UP",
      "total": 999324516352,
      "free": 691261681664,
      "threshold": 10485760
    },
    "redis": {
      "status": "DOWN",
      "error": "org.springframework.data.redis.RedisConnectionFailureException: java.net.SocketTimeoutException: Read timed out; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out"
    }
  }
  </code></pre>
  
  <p>I added the following to my Spring Boot application class:</p>
  
  <pre><code>@Bean
  JedisConnectionFactory jedisConnectionFactory() {
      return new JedisConnectionFactory();
  }
  
  @Bean
  public RedisTemplate&lt;String, Object&gt; redisTemplate() {
      RedisTemplate&lt;String, Object&gt; template = new RedisTemplate&lt;String, Object&gt;();
      template.setConnectionFactory(jedisConnectionFactory());
      return template;
  }
  </code></pre>
  
  <p>I also tried adding the following to my <code>@RestController</code> before executing some test Redis code, but I get the same error as above in the stack trace:</p>
  
  <pre><code>@Autowired
  private RedisTemplate&lt;String, String&gt; redisTemplate;
  </code></pre>
  
  <p><strong>Edit</strong> (2017-05-09)
  My understanding is that Spring Boot Redis starter assumes the default values of <code>spring.redis.host=localhost</code> and <code>spring.redis.port=6379</code>, I still added the two to <code>application.properties</code>, but that did not fill the gap.</p>
  
  <p><strong>Update</strong> (2017-05-10)
  I added an answer to this thread.</p>