我在这里看到了类似的问题,但它是针对旧版本的。不知道冲突的版本对我来说是什么,以及我需要使用什么。
我使用 Spring Initializr 来创建我的项目,遵循 SCS Reference Quick Start。这为我设置了当前版本(2.1.5,Greenwich.SR1)。
我手动添加的唯一依赖项是 RocketMQ,因为 Spring Initializr 找不到它。这是我的pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
<version>0.9.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
当我尝试关闭应用程序时,就会发生有问题的错误,这个过程每次都需要将近一分钟。这是我关闭应用程序时的完整堆栈跟踪:
无法停止 bean 'inputBindingLifecycle'
java.lang.IllegalStateException:在 java.lang.ApplicationShutdownHooks.remove(ApplicationShutdownHooks.java:82)~[na:1.8.0_181] at java.lang.Runtime.removeShutdownHook(Runtime.java:239)处正在关机~[na :1.8.0_181] 在 org.apache.rocketmq.client.trace.AsyncTraceDispatcher.removeShutdownHook(AsyncTraceDispatcher.java:210) ~[rocketmq-client-4.4.0.jar:4.4.0] 在 org.apache.rocketmq.client .trace.AsyncTraceDispatcher.shutdown(AsyncTraceDispatcher.java:183) ~[rocketmq-client-4.4.0.jar:4.4.0] at org.apache.rocketmq.client.consumer.DefaultMQPushConsumer.shutdown(DefaultMQPushConsumer.java:598) ~[rocketmq-client-4.4.0.jar:4.4.0] at org.springframework.cloud.stream.binder.rocketmq.sumption.RocketMQListenerBindingContainer.stop(RocketMQListenerBindingContainer.java:175) ~[spring-cloud-stream-binder -火箭MQ-0.9。0.RELEASE.jar:0.9.0.RELEASE] 在 org.springframework.cloud.stream.binder.rocketmq.integration.RocketMQInboundChannelAdapter.doStop(RocketMQInboundChannelAdapter.java:128) ~[spring-cloud-stream-binder-rocketmq-0.9 .0.RELEASE.jar:0.9.0.RELEASE] 在 org.springframework.integration.endpoint.AbstractEndpoint.stop(AbstractEndpoint.java:173) ~[spring-integration-core-5.1.3.RELEASE.jar:5.1。 3.RELEASE] 在 org.springframework.cloud.stream.binder.DefaultBinding.stop(DefaultBinding.java:127) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] 在 org. springframework.cloud.stream.binder.DefaultBinding.unbind(DefaultBinding.java:159) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at org.springframework.cloud.stream.binding .BindingService.unbindConsumers(BindingService.java:303) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] 在 org.springframework.cloud.stream.binding.BindableProxyFactory.unbindInputs(BindableProxyFactory.java:307) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] 在 org. springframework.cloud.stream.binding.InputBindingLifecycle.doStopWithBindable(InputBindingLifecycle.java:66) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at java.util.LinkedHashMap$LinkedValues.forEach (LinkedHashMap.java:608)~[na:1.8.0_181] at org.springframework.cloud.stream.binding.AbstractBindingLifecycle.stop(AbstractBindingLifecycle.java:56)~[spring-cloud-stream-2.1.2.RELEASE. jar:2.1.2.RELEASE] 在 org.springframework.cloud.stream.binding.InputBindingLifecycle.stop(InputBindingLifecycle.java:34) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE ] 在 org.springframework.cloud.stream.binding。AbstractBindingLifecycle.stop(AbstractBindingLifecycle.java:73) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at org.springframework.cloud.stream.binding.InputBindingLifecycle.stop(InputBindingLifecycle.java :34) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:238) [spring-context-5.1 .5.RELEASE.jar:5.1.5.RELEASE] 在 org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:53) [spring-context-5.1.5.RELEASE.jar:5.1.5。 RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:377) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.context.support .DefaultLifecycleProcessor。stopBeans(DefaultLifecycleProcessor.java:210) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:128) [spring-context -5.1.5.RELEASE.jar:5.1.5.RELEASE] 在 org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1018) [spring-context-5.1.5.RELEASE.jar:5.1.5 .RELEASE] 在 org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:945) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] ```springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1018) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext .java:945) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] ```springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1018) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext .java:945) [spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] ```