目录
問題描述
今天搭建spring cloud項目,啓動Client客戶端的時候老是啓動后就自動停了,啓動信息如下:
=======================================================以下爲啓動信息
2019-11-18 15:13:52.758 INFO 13864 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1574061232758, current=UP, previous=STARTING]
2019-11-18 15:13:52.760 INFO 13864 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_EUREKA-MEMBER/DESKTOP-L43P04V:eureka-member:9001: registering service...
2019-11-18 15:13:52.772 INFO 13864 --- [ main] com.wang.MemberApplication : Started MemberApplication in 7.167 seconds (JVM running for 8.417)
2019-11-18 15:13:52.774 INFO 13864 --- [ Thread-19] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@3c01cfa1: startup date [Mon Nov 18 15:13:48 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@2c767a52
2019-11-18 15:13:52.775 INFO 13864 --- [ Thread-19] o.s.c.n.e.s.EurekaServiceRegistry : Unregistering application eureka-member with eureka with status DOWN
2019-11-18 15:13:52.775 WARN 13864 --- [ Thread-19] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1574061232775, current=DOWN, previous=UP]
2019-11-18 15:13:52.776 INFO 13864 --- [ Thread-19] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
2019-11-18 15:13:52.777 INFO 13864 --- [ Thread-19] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2019-11-18 15:13:52.777 INFO 13864 --- [ Thread-19] com.netflix.discovery.DiscoveryClient : Unregistering ...
2019-11-18 15:13:52.782 INFO 13864 --- [ Thread-19] com.netflix.discovery.DiscoveryClient : DiscoveryClient_EUREKA-MEMBER/DESKTOP-L43P04V:eureka-member:9001 - deregister status: 200
2019-11-18 15:13:52.791 INFO 13864 --- [ Thread-19] com.netflix.discovery.DiscoveryClient : Completed shut down of DiscoveryClient
2019-11-18 15:13:52.792 INFO 13864 --- [ Thread-19] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2019-11-18 15:13:52.793 INFO 13864 --- [ Thread-19] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
Process finished with exit code 0
===================================================以上為啓動信息
然後在百度中找到各種帖子,主要是說,要引入web依賴,然後檢查我的pom文件,發現我是引入了的
<!-- springboot整合web组件 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>然後是各種鷄頭白臉(小弟是菜鳥,大佬勿噴)
無意間在idea發現這麽一條信息:

解決方法:
進入我的maven倉庫找了下,這個包是有的,但是有多個版本,於是就加了版本號:
<!-- springboot整合web组件 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>奇跡發生了,啓動成功了!!!
也就是說,如果出現這個問題,就需要在pom文件中整合web組件,并且不要忘記版本號。
以上一句才是關鍵,其他的。。。。。。我只是水一水!