小编tap*_*toe的帖子

Spring Kafka 消费者/监听器组

在消费者处指定组有什么区别

spring.kafka.consumer.group-id
Run Code Online (Sandbox Code Playgroud)

与在 @KafkaListener 指定?

@KafkaListener(topic="test", group = "test-grp")
Run Code Online (Sandbox Code Playgroud)

apache-kafka spring-kafka

6
推荐指数
1
解决办法
1万
查看次数

Spring Data JPA 和 MyBatis

我正在尝试将 Spring Data JPA 与 MyBatis 一起使用。由于 MyBatis 没有 Vendor Adapter,这里有什么替代方案?

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" value="com.abc.xyz.domain"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

当我尝试初始化我的应用程序时,出现以下异常。

Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No PersistenceProvider specified in EntityManagerFactory configuration, and chosen PersistenceUnitInfo does not specify a provider class name either
Run Code Online (Sandbox Code Playgroud)

谢谢

java mybatis spring-data-jpa spring-mybatis

5
推荐指数
2
解决办法
2万
查看次数

Spring Kafka分区

以下两个代码段在发布消息方面的行为有何不同?

方法1

Message<String> message = MessageBuilder.withPayload("testmsg")
        .setHeader(KafkaHeaders.MESSAGE_KEY, "key").setHeader(KafkaHeaders.TOPIC, "test").build();

ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send(message);
Run Code Online (Sandbox Code Playgroud)

方法2

ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send("test", "testmsg");
Run Code Online (Sandbox Code Playgroud)

主题配置:

$ bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test
Topic:test   PartitionCount:3    ReplicationFactor:1 Configs:
Topic: test  Partition: 0    Leader: 0   Replicas: 0 Isr: 0
Topic: test  Partition: 1    Leader: 0   Replicas: 0 Isr: 0
Topic: test  Partition: 2    Leader: 0   Replicas: 0 Isr: 0
Run Code Online (Sandbox Code Playgroud)

观察:

如果有3个使用者,则每个分区一个;方法1导致单个使用者从单个分区使用所有消息。采用方法2;消费在3个分区/消费者之间平均分配。

apache-kafka kafka-consumer-api kafka-producer-api spring-kafka

3
推荐指数
1
解决办法
2944
查看次数

将Spring Boot从1.5.12迁移到1.5.13后,ehcache提供错误

我已经配置了Spring Boot 1.5.12 + ehcache,一切正常,直到我将Spring Boot升级到1.5.13

application.yml 具有以下条目

spring:
  cache:
    jcache:
      provider: org.ehcache.jsr107.EhcacheCachingProvider
      config: ehcache.xml
Run Code Online (Sandbox Code Playgroud)

ehcache.xml位于resources目录下

我收到的错误是:

Caused by: java.lang.IllegalArgumentException: Cache configuration does not exist 'ServletContext resource [/ehcache.xml]'
    at org.springframework.util.Assert.isTrue(Assert.java:92)
    at org.springframework.boot.autoconfigure.cache.CacheProperties.resolveConfigLocation(CacheProperties.java:117)
    at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration.createCacheManager(JCacheCacheConfiguration.java:113)
    at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration.jCacheCacheManager(JCacheCacheConfiguration.java:97)
    at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$e5c3a047.CGLIB$jCacheCacheManager$1(<generated>)
    at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$e5c3a047$$FastClassBySpringCGLIB$$a6ae7187.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
    at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$e5c3a047.jCacheCacheManager(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    ... 47 common frames omitted
Run Code Online (Sandbox Code Playgroud)

看来Spring Boot已开始搜索ehcache.xml使用ServletContext解析器。

ps:除了将Spring Boot升级到1.5.13之外,我没有任何源代码更改

我在这里缺少一些必需的配置吗?

spring-boot spring-cache

3
推荐指数
1
解决办法
692
查看次数