SpringCloud中Client向Eureka注册中心注册服务成功后不久就Unregistering(Unregistering application 服务名 with eureka with)

在SpringCloud中Server端启动成功了,再去启动Client项目,可能会出现这样的问题,Console日志如下:

2022-06-22 16:04:41.990  INFO 14964 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:9001/
2022-06-22 16:04:42.560  INFO 14964 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=config, profiles=[test], label=master, version=28afd1f94d37c7a7fc60e402dab302bb178fae5c, state=null
2022-06-22 16:04:42.560  INFO 14964 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://gitee.com/llongtong/zeno-training-platform-config.git/file:C:\Users\SAMSUNG\AppData\Local\Temp\config-repo-7871456846147239475\config-test.yml'}]
2022-06-22 16:04:42.576  INFO 14964 --- [           main] com.zeno.ConfigClientTestApplication     : No active profile set, falling back to default profiles: default
2022-06-22 16:04:42.866  INFO 14964 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=788e2244-e364-3193-959b-c9162cfcdae6
2022-06-22 16:04:43.971  INFO 14964 --- [           main] DiscoveryClientOptionalArgsConfiguration : Eureka HTTP Client uses RestTemplate.
2022-06-22 16:04:44.845  WARN 14964 --- [           main] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
2022-06-22 16:04:44.892  INFO 14964 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2022-06-22 16:04:44.923  INFO 14964 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2022-06-22 16:04:44.923  INFO 14964 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2022-06-22 16:04:44.939  INFO 14964 --- [           main] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2022-06-22 16:04:44.939  INFO 14964 --- [           main] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2022-06-22 16:04:44.939  INFO 14964 --- [           main] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2022-06-22 16:04:44.939  INFO 14964 --- [           main] com.netflix.discovery.DiscoveryClient    : Application is null : false
2022-06-22 16:04:44.939  INFO 14964 --- [           main] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2022-06-22 16:04:44.939  INFO 14964 --- [           main] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2022-06-22 16:04:44.939  INFO 14964 --- [           main] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2022-06-22 16:04:45.111  INFO 14964 --- [           main] com.netflix.discovery.DiscoveryClient    : The response status is 200
2022-06-22 16:04:45.111  INFO 14964 --- [           main] com.netflix.discovery.DiscoveryClient    : Starting heartbeat executor: renew interval is: 30
2022-06-22 16:04:45.111  INFO 14964 --- [           main] c.n.discovery.InstanceInfoReplicator     : InstanceInfoReplicator onDemand update allowed rate per min is 4
2022-06-22 16:04:45.111  INFO 14964 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1655885085111 with initial instances count: 3
2022-06-22 16:04:45.111  INFO 14964 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application CONFIG-CLIENT with eureka with status UP
2022-06-22 16:04:45.111  INFO 14964 --- [           main] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1655885085111, current=UP, previous=STARTING]
2022-06-22 16:04:45.126  INFO 14964 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CONFIG-CLIENT/LONGTONG.mshome.net:config-client:8453: registering service...
2022-06-22 16:04:45.126  INFO 14964 --- [           main] com.zeno.ConfigClientTestApplication     : Started ConfigClientTestApplication in 5.828 seconds (JVM running for 8.011)
2022-06-22 16:04:45.142  INFO 14964 --- [ionShutdownHook] o.s.c.n.e.s.EurekaServiceRegistry        : Unregistering application CONFIG-CLIENT with eureka with status DOWN
2022-06-22 16:04:45.142  INFO 14964 --- [ionShutdownHook] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1655885085142, current=DOWN, previous=UP]
2022-06-22 16:04:45.142  INFO 14964 --- [ionShutdownHook] com.netflix.discovery.DiscoveryClient    : Shutting down DiscoveryClient ...
2022-06-22 16:04:45.173  INFO 14964 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CONFIG-CLIENT/LONGTONG.mshome.net:config-client:8453 - registration status: 204
2022-06-22 16:04:45.173  INFO 14964 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CONFIG-CLIENT/LONGTONG.mshome.net:config-client:8453: registering service...
2022-06-22 16:04:45.173  INFO 14964 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CONFIG-CLIENT/LONGTONG.mshome.net:config-client:8453 - registration status: 204
2022-06-22 16:04:45.173  INFO 14964 --- [ionShutdownHook] com.netflix.discovery.DiscoveryClient    : Unregistering ...
2022-06-22 16:04:45.173  INFO 14964 --- [ionShutdownHook] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CONFIG-CLIENT/LONGTONG.mshome.net:config-client:8453 - deregister  status: 200
2022-06-22 16:04:45.189  INFO 14964 --- [ionShutdownHook] com.netflix.discovery.DiscoveryClient    : Completed shut down of DiscoveryClient

Process finished with exit code 0

 其中,出了问题的大概可以从这里排查。 

前面显示注册成功了,现在立马又开始倒戈。这是由于可能SpringWeb依赖是继承父模块的,所以我们这个模块里没有写Web依赖。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

在我们这个模块pom文件里加上web依赖就搞定了。 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值