springcloud项目启动以后没注册到nacos

根本原因:没有依赖

问题过程

项目启动成功之后的截图 

 

可以看到nacos只有网关,并没有flight-query这个服务

<nacos.discovery.version>2.2.3.RELEASE</nacos.discovery.version>     
   <!--nacos服务注册依赖-->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>

加上这个以来以后,然后重新启动


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.2.RELEASE)

05-03 00:12:29:741  INFO 12816 --- [           main] com.yinpeng.FlightQueryApplication       : No active profile set, falling back to default profiles: default
05-03 00:12:30:729  INFO 12816 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=7efd81b2-1f4b-3e7e-9a93-d51d4132a64d
05-03 00:12:31:168  INFO 12816 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8084 (http)
05-03 00:12:31:181  INFO 12816 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
05-03 00:12:31:181  INFO 12816 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.37]
05-03 00:12:31:418  INFO 12816 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
05-03 00:12:31:419  INFO 12816 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1656 ms
05-03 00:12:31:872  WARN 12816 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
05-03 00:12:31:872  INFO 12816 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
05-03 00:12:31:879  WARN 12816 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
05-03 00:12:31:879  INFO 12816 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
05-03 00:12:32:074  INFO 12816 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
05-03 00:12:32:793  INFO 12816 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'Nacos-Watch-Task-Scheduler'
05-03 00:12:33:833  INFO 12816 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8084 (http) with context path ''
05-03 00:12:33:853  INFO 12816 --- [           main] c.a.c.n.registry.NacosServiceRegistry    : nacos registry, DEFAULT_GROUP flight-query 192.168.157.1:8084 register finished
05-03 00:12:34:374  INFO 12816 --- [           main] com.yinpeng.FlightQueryApplication       : Started FlightQueryApplication in 8.076 seconds (JVM running for 11.168)
05-03 00:13:50:209  INFO 12816 --- [nio-8084-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
05-03 00:13:50:209  INFO 12816 --- [nio-8084-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
05-03 00:13:50:220  INFO 12816 --- [nio-8084-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 11 ms

可以看到一句

05-03 00:12:33:853  INFO 12816 --- [           main] c.a.c.n.registry.NacosServiceRegistry    : nacos registry, DEFAULT_GROUP flight-query 192.168.157.1:8084 register finished
说明nacos已经注册了

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值