org.springframework.data.redis.core.RedisHash has a field timeToLive typed as long therefor you cannot use SPeL/Spring-style expression.

timeToLive is often a property coming from env properties and therefor pass from parameter. The current definition of @RedisHash is @RedisHash(value="myIndex", timeToLive=60)

The issue seems to come from a long running issue (compiler issue) here @Scheduler SpringBoot @RedisHash timeToLive is a long, which is not compatible with the use of SPeL

However this is annoying because that force user of @RedisHash to define all index/entity globally using RedisMappingContext bean

    @Bean
    public RedisMappingContext keyValueMappingContext() {
        return new RedisMappingContext(new MappingConfiguration(new IndexConfiguration(), new MyKeyspaceConfiguration()));
    }

    public class MyKeyspaceConfiguration extends KeyspaceConfiguration {

        @Override
        protected Iterable<KeyspaceSettings> initialConfiguration() {
            KeyspaceSettings keyspace = new KeyspaceSettings(Index.class, "myindex:Index");
            keyspace.setTimeToLive(MyIndex.getTtlInSeconds().longValue());
            return Collections.singleton(keyspace);
        }
    }

Comment From: wilkinsona

This is out of Spring Boot's control. RedisHash is part of Spring Data Redis. SPeL and @Scheduled are part of Spring Framework.