JedisConnectionFactory 的方法已弃用。在 Spring 批处理中使用哪些 XML 配置?

Methods of JedisConnectionFactory is deprecated. Which XML configuations to used in Spring Batch?

我正在 Spring batch 中开发一个实用程序,将从 Mysql/Oracle 读取数据并将其写入 Redis 数据库。

目前我们仍在使用 Spring 基于批处理 XML 的配置(我们仍然喜欢基于 XML 的配置 - 对我们几乎没有控制权: ))

当我配置以下内容时,我发现大多数方法都已 弃用。

<bean id="redisDataSource" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
        <property name=""></property>
</bean>

使用以下依赖版本:

<properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring-batch-vesion>4.0.1.RELEASE</spring-batch-vesion>
        <mysql.version>8.0.11</mysql.version>
        <logback.version>1.2.3</logback.version>
        <jcl.slf4j.version>1.7.25</jcl.slf4j.version>
        <quartz.version>2.2.1</quartz.version>
        <spring.version>5.0.0.RELEASE</spring.version>
        <lombok.version>1.18.0</lombok.version>
        <jedis.version>2.9.0</jedis.version>
</properties>

任何人都可以建议我应该用来配置数据源的基于 XML 的配置吗?

我参考了 link: https://docs.spring.io/spring-data/redis/docs/2.0.8.RELEASE/reference/html/,但我不清楚。

STS 片段:

经过大量研究和谷歌搜索后,找到了以下有用的链接:

  1. Weird redis key with spring data Jedis
  2. Spring Data RedisTemplate: Serializing the Value and HashValue
  3. https://github.com/hantsy/spring-sandbox/blob/master/spring-cache/src/main/java/com/hantsylabs/example/spring/config/applicationContext-jpa-redis.xml

这是代码片段:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:p="http://www.springframework.org/schema/p" xmlns:task="http://www.springframework.org/schema/task" 
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="  http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans.xsd  
      http://www.springframework.org/schema/util  http://www.springframework.org/schema/util/spring-util.xsd     
      http://www.springframework.org/schema/tx  http://www.springframework.org/schema/tx/spring-tx.xsd     
      http://www.springframework.org/schema/task  http://www.springframework.org/schema/task/spring-task.xsd">

   <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
      <property name="maxTotal" value="200" />
      <property name="maxIdle" value="50" />
      <property name="maxWaitMillis" value="3000" />
      <property name="testOnBorrow" value="true" />
   </bean>

   <bean id="jedisFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
      <property name="hostName" value="${redis_ip}" />
      <property name="port" value="${redis_port}" />
      <property name="poolConfig" ref="jedisPoolConfig" />
      <property name="usePool" value="true" />
   </bean>

   <bean id="stringRedisSerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer" />
   <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" p:connection-factory-ref="jedisFactory" p:valueSerializer-ref="stringRedisSerializer"          
         p:keySerializer-ref="stringRedisSerializer" />
</beans>

或简单地使用https://docs.spring.io/spring-integration/reference/html/redis.html