我正在尝试配置为Spring Integration应用程序的中间件。
这是application.yml文件:
spring:
application:
name: ${vcap.application.name:}
cloud:
stream:
bindings:
myOutput:
destination: myInput
default-binder: rabbit
我得到的错误是:
nested exception is java.lang.IllegalStateException: Unknown binder configuration: rabbit
关于如何正确配置Rabbit以进行sprint集成的任何想法。
该项目分为多个模块,该代码来自组织的先前开发人员。因此我可能无法回答所有“为什么”问题,但这是:
模块1:Source Gradle文件:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'io.spring.dependency-management'
dependencies {
compile project(':mds-dealer-redcap-common')
// spring dependencies
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-amqp'
compile 'org.springframework.boot:spring-boot-starter-actuator'
// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-stream-rabbit
compile 'org.springframework.cloud:spring-cloud-stream'
// https://mvnrepository.com/artifact/org.springframework.cloud.stream.app/spring-cloud-starter-stream-source-time
compile 'org.springframework.cloud.stream.app:spring-cloud-starter-stream-source-time:2.0.0.RC1'
}
模块2:同步gradle文件
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'maven-publish'
dependencies {
compile project(':mds-dealer-redcap-common')
// spring dependencies
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-amqp'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.cloud:spring-cloud-starter-stream-rabbit'
//core common modules
compile ('common:common-domain:latest.integration')
// database dependencies
compile('org.springframework.boot:spring-boot-starter-data-mongodb')
// compile 'org.springframework.data:spring-data-mongodb:1.10.0.RELEASE'
// others
compile 'org.glassfish.jersey.core:jersey-client:2.23'
//Logging dependency
compile 'org.slf4j:slf4j-api'
//test dependencies
testCompile 'org.springframework.boot:spring-boot-starter-test:2.1.5.RELEASE'
testCompile 'junit:junit:4.12'
}
模块3:处理器
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
dependencies {
compile project(':mds-dealer-redcap-common')
// spring dependencies
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-amqp'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.cloud:spring-cloud-starter-stream-rabbit'
compile 'org.glassfish.jersey.core:jersey-client:2.23'
//core common modules
compile ('common:common-domain:latest.integration')
// database dependencies
compile('org.springframework.boot:spring-boot-starter-data-mongodb')
// compile 'org.springframework.data:spring-data-mongodb:1.10.0.RELEASE'
//Logging dependency
compile 'org.slf4j:slf4j-api'
//test dependencies
testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile 'junit:junit:4.12'
}
主要应用Gradle片段:
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: "io.spring.dependency-management"dependencies {
compile project(':mds-dealer-redcap-common'), project(':mds-dealer-redcap-source'), project(':mds-dealer-redcap-processor'), project(':mds-dealer-redcap-sink')
// spring dependencies
compile 'org.springframework.cloud:spring-cloud-starter-stream-rabbit'
compile 'org.springframework.cloud:spring-cloud-stream'
compile 'org.springframework.boot:spring-boot-configuration-processor'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile('common:responseheaders:latest.integration'){ changing=true }
compile 'org.slf4j:slf4j-api:1.7.21'
testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile 'junit:junit:4.12'
}
这一切是如何开始的:
public static void main(String[] args) {
new AggregateApplicationBuilder(DealerRedcapIngestionStarter.class)
.from(StreamTrigger.class)
.via(DealerRedcapProcessor.class)
.to(DealerRedcapSink.class).run(args);
}
对于依赖项的版本,我使用的是这个:
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Greenwich.SR1'
mavenBom "org.springframework.boot:spring-boot-starter:${springBootVersion}"
}
}
spring boot版本是2.1.5.RELEASE
答案 0 :(得分:0)
除非类路径上有多个活页夹,否则您实际上并不需要default-binder
属性-请参见the reference guide。
但是,此错误表示您在类路径上没有兔子活页夹。
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
编辑
这是当选择Spring Cloud Stream
和Spring for RabbitMQ
时由start.spring.io构建的初始build.gradle。
plugins {
id 'org.springframework.boot' version '2.1.6.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "Greenwich.SR2")
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-amqp'
implementation 'org.springframework.cloud:spring-cloud-stream'
implementation 'org.springframework.cloud:spring-cloud-stream-binder-rabbit'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.cloud:spring-cloud-stream-test-support'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
这些就是由此产生的依赖性...
compileClasspath - Compile classpath for source set 'main'.
+--- org.springframework.boot:spring-boot-starter-amqp -> 2.1.6.RELEASE
| +--- org.springframework.boot:spring-boot-starter:2.1.6.RELEASE
| | +--- org.springframework.boot:spring-boot:2.1.6.RELEASE
| | | +--- org.springframework:spring-core:5.1.8.RELEASE
| | | | \--- org.springframework:spring-jcl:5.1.8.RELEASE
| | | \--- org.springframework:spring-context:5.1.8.RELEASE
| | | +--- org.springframework:spring-aop:5.1.8.RELEASE
| | | | +--- org.springframework:spring-beans:5.1.8.RELEASE
| | | | | \--- org.springframework:spring-core:5.1.8.RELEASE (*)
| | | | \--- org.springframework:spring-core:5.1.8.RELEASE (*)
| | | +--- org.springframework:spring-beans:5.1.8.RELEASE (*)
| | | +--- org.springframework:spring-core:5.1.8.RELEASE (*)
| | | \--- org.springframework:spring-expression:5.1.8.RELEASE
| | | \--- org.springframework:spring-core:5.1.8.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-autoconfigure:2.1.6.RELEASE
| | | \--- org.springframework.boot:spring-boot:2.1.6.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-starter-logging:2.1.6.RELEASE
| | | +--- ch.qos.logback:logback-classic:1.2.3
| | | | +--- ch.qos.logback:logback-core:1.2.3
| | | | \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.26
| | | +--- org.apache.logging.log4j:log4j-to-slf4j:2.11.2
| | | | +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.26
| | | | \--- org.apache.logging.log4j:log4j-api:2.11.2
| | | \--- org.slf4j:jul-to-slf4j:1.7.26
| | | \--- org.slf4j:slf4j-api:1.7.26
| | +--- javax.annotation:javax.annotation-api:1.3.2
| | \--- org.springframework:spring-core:5.1.8.RELEASE (*)
| +--- org.springframework:spring-messaging:5.1.8.RELEASE
| | +--- org.springframework:spring-beans:5.1.8.RELEASE (*)
| | \--- org.springframework:spring-core:5.1.8.RELEASE (*)
| \--- org.springframework.amqp:spring-rabbit:2.1.7.RELEASE
| +--- org.springframework.amqp:spring-amqp:2.1.7.RELEASE
| | +--- org.springframework:spring-core:5.1.8.RELEASE (*)
| | \--- org.springframework.retry:spring-retry:1.2.4.RELEASE
| | \--- org.springframework:spring-core:4.3.22.RELEASE -> 5.1.8.RELEASE (*)
| +--- com.rabbitmq:amqp-client:5.4.3
| | \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.26
| +--- org.springframework:spring-context:5.1.8.RELEASE (*)
| +--- org.springframework:spring-messaging:5.1.8.RELEASE (*)
| \--- org.springframework:spring-tx:5.1.8.RELEASE
| +--- org.springframework:spring-beans:5.1.8.RELEASE (*)
| \--- org.springframework:spring-core:5.1.8.RELEASE (*)
+--- org.springframework.cloud:spring-cloud-stream -> 2.1.3.RELEASE
| +--- org.springframework.boot:spring-boot-starter-validation:2.1.3.RELEASE -> 2.1.6.RELEASE
| | +--- org.springframework.boot:spring-boot-starter:2.1.6.RELEASE (*)
| | +--- org.apache.tomcat.embed:tomcat-embed-el:9.0.21
| | \--- org.hibernate.validator:hibernate-validator:6.0.17.Final
| | +--- javax.validation:validation-api:2.0.1.Final
| | +--- org.jboss.logging:jboss-logging:3.3.2.Final
| | \--- com.fasterxml:classmate:1.3.4 -> 1.4.0
| +--- org.springframework:spring-messaging:5.1.5.RELEASE -> 5.1.8.RELEASE (*)
| +--- org.springframework.integration:spring-integration-core:5.1.3.RELEASE -> 5.1.6.RELEASE
| | +--- org.springframework:spring-core:5.1.8.RELEASE (*)
| | +--- org.springframework:spring-aop:5.1.8.RELEASE (*)
| | +--- org.springframework:spring-context:5.1.8.RELEASE (*)
| | +--- org.springframework:spring-messaging:5.1.8.RELEASE (*)
| | +--- org.springframework:spring-tx:5.1.8.RELEASE (*)
| | +--- org.springframework.retry:spring-retry:1.2.4.RELEASE (*)
| | \--- io.projectreactor:reactor-core:3.2.10.RELEASE
| | \--- org.reactivestreams:reactive-streams:1.0.2
| +--- org.springframework.integration:spring-integration-jmx:5.1.3.RELEASE -> 5.1.6.RELEASE
| | \--- org.springframework.integration:spring-integration-core:5.1.6.RELEASE (*)
| +--- org.springframework:spring-tuple:1.0.0.RELEASE
| | +--- com.esotericsoftware:kryo-shaded:3.0.3
| | | +--- com.esotericsoftware:minlog:1.3.0
| | | \--- org.objenesis:objenesis:2.1
| | +--- org.springframework:spring-core:4.2.6.RELEASE -> 5.1.8.RELEASE (*)
| | +--- com.fasterxml.jackson.core:jackson-databind:2.6.6 -> 2.9.9
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0
| | | \--- com.fasterxml.jackson.core:jackson-core:2.9.9
| | \--- org.springframework:spring-context:4.2.6.RELEASE -> 5.1.8.RELEASE (*)
| +--- org.springframework.integration:spring-integration-tuple:1.0.0.RELEASE
| | +--- org.springframework:spring-tuple:1.0.0.RELEASE (*)
| | \--- org.springframework.integration:spring-integration-core:4.2.5.RELEASE -> 5.1.6.RELEASE (*)
| +--- org.springframework.retry:spring-retry:1.2.4.RELEASE (*)
| \--- org.springframework.cloud:spring-cloud-function-context:2.0.1.RELEASE -> 2.0.2.RELEASE
| +--- org.springframework.boot:spring-boot-autoconfigure:2.1.3.RELEASE -> 2.1.6.RELEASE (*)
| +--- org.springframework.cloud:spring-cloud-function-core:2.0.2.RELEASE
| | +--- io.projectreactor:reactor-core:3.2.6.RELEASE -> 3.2.10.RELEASE (*)
| | \--- org.springframework:spring-core:5.1.5.RELEASE -> 5.1.8.RELEASE (*)
| \--- org.springframework:spring-messaging:5.1.5.RELEASE -> 5.1.8.RELEASE (*)
\--- org.springframework.cloud:spring-cloud-stream-binder-rabbit -> 2.1.3.RELEASE
+--- org.springframework.cloud:spring-cloud-stream-binder-rabbit-core:2.1.3.RELEASE
| +--- org.springframework.cloud:spring-cloud-stream:2.1.3.RELEASE (*)
| +--- org.springframework.boot:spring-boot-starter-amqp:2.1.3.RELEASE -> 2.1.6.RELEASE (*)
| +--- org.springframework.integration:spring-integration-amqp:5.1.3.RELEASE -> 5.1.6.RELEASE
| | +--- org.springframework.integration:spring-integration-core:5.1.6.RELEASE (*)
| | \--- org.springframework.amqp:spring-rabbit:2.1.7.RELEASE (*)
| +--- org.springframework:spring-web:5.1.5.RELEASE -> 5.1.8.RELEASE
| | +--- org.springframework:spring-beans:5.1.8.RELEASE (*)
| | \--- org.springframework:spring-core:5.1.8.RELEASE (*)
| +--- org.apache.httpcomponents:httpclient:4.5.7 -> 4.5.9
| | +--- org.apache.httpcomponents:httpcore:4.4.11
| | \--- commons-codec:commons-codec:1.11
| \--- com.rabbitmq:http-client:2.1.0.RELEASE
| \--- com.fasterxml.jackson.core:jackson-databind:2.9.5 -> 2.9.9 (*)
+--- org.springframework.cloud:spring-cloud-stream:2.1.3.RELEASE (*)
+--- org.springframework.boot:spring-boot-starter-amqp:2.1.3.RELEASE -> 2.1.6.RELEASE (*)
+--- org.springframework.integration:spring-integration-amqp:5.1.3.RELEASE -> 5.1.6.RELEASE (*)
+--- org.springframework.integration:spring-integration-core:5.1.3.RELEASE -> 5.1.6.RELEASE (*)
+--- org.springframework.integration:spring-integration-jmx:5.1.3.RELEASE -> 5.1.6.RELEASE (*)
\--- org.apache.httpcomponents:httpclient:4.5.6 -> 4.5.9 (*)