Commit cf71cf88 authored by xiaoguang.xu's avatar xiaoguang.xu

fix : 修复了一个项目没有MQ,graceful-shutdown 启动报错的问题

parent 713c8454
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<version>0.2.5</version> <version>0.2.5.1</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<version>0.2.5</version> <version>0.2.5.1</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<version>0.2.5</version> <version>0.2.5.1</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
...@@ -77,7 +77,12 @@ ...@@ -77,7 +77,12 @@
<version>2.8.8</version> <version>2.8.8</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!--这个可以让我们项目启动速度有质的飞跃-->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.13</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<version>0.2.5</version> <version>0.2.5.1</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<version>0.2.5</version> <version>0.2.5.1</version>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<lombok.version>1.16.20</lombok.version> <lombok.version>1.16.20</lombok.version>
<guava.version>23.0</guava.version> <guava.version>23.0</guava.version>
<apollo.client.version>0.10.2</apollo.client.version> <apollo.client.version>0.10.2</apollo.client.version>
<common.parent.version>0.2.5</common.parent.version> <common.parent.version>0.2.5.1</common.parent.version>
</properties> </properties>
<dependencies> <dependencies>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<version>0.2.5</version> <version>0.2.5.1</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.config.RabbitListenerConfigUtils; import org.springframework.amqp.rabbit.config.RabbitListenerConfigUtils;
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry; import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.Lifecycle; import org.springframework.context.Lifecycle;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -20,6 +21,10 @@ import javax.annotation.PreDestroy; ...@@ -20,6 +21,10 @@ import javax.annotation.PreDestroy;
@Configuration @Configuration
public class BaseDestroyHandler { public class BaseDestroyHandler {
@Configuration
@ConditionalOnClass(RabbitListenerEndpointRegistry.class)
public static class DestroyMessageQueueListener {
@Autowired @Autowired
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
...@@ -36,11 +41,6 @@ public class BaseDestroyHandler { ...@@ -36,11 +41,6 @@ public class BaseDestroyHandler {
} }
} }
@PreDestroy
private void stopRedisSub() {
log.info("我什么都没做, redis stopped");
}
@PreDestroy @PreDestroy
private void stopRabbitMQ() { private void stopRabbitMQ() {
try { try {
...@@ -55,4 +55,14 @@ public class BaseDestroyHandler { ...@@ -55,4 +55,14 @@ public class BaseDestroyHandler {
} }
log.info("MQ listener stopped"); log.info("MQ listener stopped");
} }
}
@PreDestroy
private void stopOther() {
log.info("我什么都没做, other stopped");
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment