Giter Site home page Giter Site logo

Comments (3)

mp911de avatar mp911de commented on September 26, 2024

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal yet complete sample that reproduces the problem.
You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

from spring-data-redis.

UnfetteredCodeMan avatar UnfetteredCodeMan commented on September 26, 2024

This is my redis configuration class

@Configuration
class MyConfig {

  @Bean
  LettuceConnectionFactory connectionFactory() {
    return new LettuceConnectionFactory();
  }

  @Bean
  ReactiveRedisTemplate<String, String> ReactiveRedisTemplate(ReactoveRedisConnectionFactory connectionFactory) {
    return new ReactiveRedisTemplate<>(connectionFactory, RedisSerializationContext.string());
  }
}

This is my project maven environment

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.5</version>
        <relativePath/> <!-- lookup parent from repository -->
</parent>
 <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis-reactive</artifactId>
        </dependency>
 </dependencies>

And I configured the host,password&port in application.properties

spring.data.redis.host=xxx.com
spring.data.redis.port=14777
spring.data.redis.password=xxxxx

Then I wrote a test case intending to pass a list data to my Redis remote server

    @Qualifier("ReactiveRedisTemplate")
    @Autowired
    private ReactiveRedisOperations<String, String> operations;
    public Mono<Long> addLink(String userId, String url) {
        return operations.opsForList().leftPush(userId, url);
    }
    @Test
    void testA() {
        Mono<Long> mono = addLink("tks1", "http://google.com");
        log.info("mono: {}", mono.block());
    }

And then an error.The error message is as follows:

  1. org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis
  2. Unable to connect to localhost/:6379
  3. Connection refused: no further information: localhost/127.0.0.1:6379

But I can connect to the Redis server by way of RedisStandaloneConfiguration:

@Configuration
class MyConfig {

  @Bean
  LettuceConnectionFactory connectionFactory() {
    RedisStandaloneConfiguration serverConfig = new RedisStandaloneConfiguration("xxx.com", 14777);
        serverConfig.setPassword("xxxxx");
        return new LettuceConnectionFactory(serverConfig, clientConfig);
  }

  @Bean
  ReactiveRedisTemplate<String, String> ReactiveRedisTemplate(ReactoveRedisConnectionFactory connectionFactory) {
    return new ReactiveRedisTemplate<>(connectionFactory, RedisSerializationContext.string());
  }
}

Then the data was uploaded successfully

INFO 3296 --- [ main] p.l.LearnSpringBootApplicationTest : mono: 1

So, spring-boot-starter-data-redis with version 3.2.5 unable to configure Redis startup configurations by modifying configuration files such as application.properties?
@mp911de

from spring-data-redis.

josue270193 avatar josue270193 commented on September 26, 2024

Hello, I'm having the same issue. I did what @UnfetteredCodeMan mentions to solved my problem, using the application.properties doesn't work at all. In my case, I use spring boot 3.3.0 and redisStandalone.

from spring-data-redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.