简体   繁体   English

Spring Boot:Spring Cloud Stream Kafka实现

[英]Spring Boot: Spring Cloud Stream Kafka implementation

It seems to be very straightforward implementation with just 2 libraries specific to cloud stream project but I am getting 这似乎是非常简单的实现,只有2个特定于云流项目的库,但是我正在
java.lang.ClassNotFoundException: org.springframework.integration.support.converter.ConfigurableCompositeMessageConverter

All the dependencies in the project are: 项目中的所有依赖项是:

compile(
    "org.springframework.boot:spring-boot-starter-web", 
    "org.springframework.boot:spring-boot-starter-actuator",
    "org.springframework.boot:spring-boot-starter-data-rest",
    "org.springframework.boot:spring-boot-starter-data-jpa",
    "org.springframework.boot:spring-boot-starter-security",
    "org.springframework.boot:spring-boot-starter-amqp",
    "org.springframework.cloud:spring-cloud-stream",
    "org.springframework.cloud:spring-cloud-starter-stream-kafka",
    "org.postgresql:postgresql:9.4.1212.jre7",
    "org.projectlombok:lombok:1.16.14",
    "io.jsonwebtoken:jjwt:0.7.0",
    "org.flywaydb:flyway-core:4.2.0"
    )

Cloud stream configuration: 云流配置:

spring.application.name=services
spring.stream.bindings.output.destination=appTopic
spring.stream.bindings.output.content-type=application/json
spring.stream.bindings.kafka.binder.zkNodes=${HOST}
spring.stream.bindings.kafka.binder.brokers=${HOST}

Complete build.gradle: 完成build.gradle:

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE")
        classpath "gradle.plugin.com.boxfuse.client:flyway-release:4.2.0"
        classpath "io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE"
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'org.flywaydb.flyway'
apply plugin: "io.spring.dependency-management"

ext {
    springBootVersion = '1.5.2.RELEASE'
}

jar {
    baseName = 'rest'
    version = '0.1'
}

repositories {
    mavenCentral()
}

dependencyManagement {
     imports {
          mavenBom 'org.springframework.cloud:spring-cloud-stream-dependencies:Elmhurst.BUILD-SNAPSHOT'
     }
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile(
    "org.springframework.boot:spring-boot-starter-web", 
    "org.springframework.boot:spring-boot-starter-actuator",
    "org.springframework.boot:spring-boot-starter-data-rest",
    "org.springframework.boot:spring-boot-starter-data-jpa",
    "org.springframework.boot:spring-boot-starter-security",
    "org.springframework.boot:spring-boot-starter-amqp",
    "org.springframework.cloud:spring-cloud-stream",
    "org.springframework.cloud:spring-cloud-starter-stream-kafka",
    "org.springframework.integration:spring-integration-core",
    "org.postgresql:postgresql:9.4.1212.jre7",
    "org.projectlombok:lombok:1.16.14",
    "io.jsonwebtoken:jjwt:0.7.0",
    "org.flywaydb:flyway-core:4.2.0"
    )
    testCompile(
    "org.springframework.boot:spring-boot-starter-test",
    "com.jayway.jsonpath:json-path",
    "org.flywaydb.flyway-test-extensions:flyway-spring-test:4.2.0",
    "io.rest-assured:rest-assured:3.0.3"
    )
}
repositories {
    maven {
        url 'https://repo.spring.io/libs-snapshot'
    }
}

The org.springframework.integration.support.converter.ConfigurableCompositeMessageConverter is from Spring Integration 5.0 : org.springframework.integration.support.converter.ConfigurableCompositeMessageConverter来自Spring Integration 5.0

/**
 * A {@link CompositeMessageConverter} extension with some default {@link MessageConverter}s
 * which can be overridden with the given converters
 * or added in the end of target {@code converters} collection.
 * <p>
 * The default converts are (declared exactly in this order):
 * <ul>
 *  <li> {@link MappingJackson2MessageConverter} if Jackson processor is present in classpath;
 *  <li> {@link ByteArrayMessageConverter}
 *  <li> {@link ObjectStringMessageConverter}
 *  <li> {@link GenericMessageConverter}
 * </ul>
 *
 * @author Artem Bilan
 *
 * @since 5.0
 */
public class ConfigurableCompositeMessageConverter extends CompositeMessageConverter {

You should be sure that you use compatible versions in your application. 您应确保在应用程序中使用兼容版本。

You appear to have mismatched versions ConfigurableCompositeMessageConverter is a new class in Spring Integration 5.0. 您似乎具有不匹配的版本ConfigurableCompositeMessageConverter是Spring Integration 5.0中的新类。

What boot version are you using? 您正在使用什么启动版本? What spring-cloud-stream versions? 哪些spring-cloud-stream版本?

Spring Cloud Stream is not currently compatible with Spring Boot 2.0 snapshots (if that's what you are using). Spring Cloud Stream当前与Spring Boot 2.0快照不兼容(如果正在使用的话)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM