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

  • Post author:
  • Post category:其他


根本原因:没有依赖

问题过程

项目启动成功之后的截图

可以看到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已经注册了



版权声明:本文为qq_44624290原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。