当前位置: 首页 > 知识库问答 >
问题:

不推荐使用JedisConnectionFactory的方法。Spring Batch中使用哪些XML配置?

曾景龙
2023-03-14

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

目前,我们仍然使用基于XML的Spring批处理配置(我们仍然喜欢基于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>

共有1个答案

潘辰龙
2023-03-14

经过大量的研究和谷歌搜索,发现以下有用的链接:

  1. 带有spring data Jedis的奇怪redis键
  2. Spring Data redistemplate:序列化值和HashValue
  3. https://github.com/hantsy/spring-sandbox/blob/master/spring-cache/src/main/java/com/hantsylabs/example/spring/config/applicationcontext-jpa-redis.xml
  4. 使用RedisTemplate从Redis获取设置值

下面是代码片段:

<?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>
 类似资料:
  • 我使用hystrix api版本1.5.4。我看到的方法已被弃用。替代方法是什么?

  • 问题内容: 我已经看到了许多在API上使用注释以将其标记为“需要尽快替换”的示例。 但是,在几乎所有这些情况下,代码开发人员不仅继续使用已弃用的API,而且还抑制了弃用警告。 似乎API开发人员的最佳意图最终是创建更多与已实现的业务逻辑无关的代码- 如果不赞成使用API​​,但在抑制相关警告的情况下继续使用它,则似乎充其量只是代码的降级,并且在IMHO最差的情况下替换不推荐使用的库时,可能会导致应

  • 本文向大家介绍mysql中的limit用法有哪些(推荐),包括了mysql中的limit用法有哪些(推荐)的使用技巧和注意事项,需要的朋友参考一下 1.m代表从m+1条记录行开始检索,n代表取出n条数据。(m可设为0) 如:SELECT * FROM 表名 limit 6,5; 表示:从第7条记录行开始算,取出5条数据 2.值得注意的是,n可以被设置为-1,当n为-1时,表示从m+1行开始检索,直

  • 问题内容: 我在java 6上。用于读取用户输入。不推荐使用readLine()的情况。读取用户价值的方法是什么? 请在不建议使用readLine()时进行解释。 问题答案: 从根本上说是二进制结构。如果要读取 文本 数据(例如从控制台),则应使用某种描述。要将转换为,请使用。然后在周围创建一个,您可以使用读取一行。 更多选择: 使用内置回合,然后致电 使用(从中获得)并致电

  • 问题内容: 不推荐使用此调用: 在源文件中,我可以看到以下内容: 但是我不明白我必须使用哪种方法代替。 问题答案: 您可以在Hibernate 5.2 +中使用以下接口:

  • 问题内容: 我正在使用org.apache.poi 3.15读取一个excel文件(文件扩展名为xlsx)。 这是我的代码: 我收到不推荐使用的警告。谁能告诉我替代方法? 问题答案: 接受的答案显示了弃用的原因,但未列出替代项: 其中是描述单元格类型的枚举。 计划是在POI 4.0中重命名回。