zoukankan      html  css  js  c++  java
  • 网关

    1、注册“gulimall-gateway”到Nacos

    1)创建“gulimall-gateway”

    SpringCloud gateway

    2)添加“gulimall-common”依赖和“spring-cloud-starter-gateway”依赖

            <dependency>
                <groupId>com.bigdata.gulimall</groupId>
                <artifactId>gulimall-common</artifactId>
                <version>1.0-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-gateway</artifactId>
            </dependency>
    

      

    3)“com.bigdata.gulimall.gulimallgateway.GulimallGatewayApplication”类上加上“@EnableDiscoveryClient”注解

    4)在Nacos中创建“gateway”命名空间,同时在该命名空间中创建“gulimall-gateway.yml”

    5)创建“bootstrap.properties”文件,添加如下配置,指明配置中心地址和所属命名空间

    spring.application.name=gulimall-gateway
    spring.cloud.nacos.config.server-addr=192.168.137.14:8848
    spring.cloud.nacos.config.namespace=1c82552e-1af0-4ced-9a48-26f19c2d315f
    

      

    6)创建“application.properties”文件,指定服务名和注册中心地址

    spring.application.name=gulimall-gateway
    spring.cloud.nacos.discovery.server-addr=192.168.137.14:8848
    server.port=88
    

      

    7)启动“gulimall-gateway”

    启动报错:

    Description:
    
    Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
    
    Reason: Failed to determine a suitable driver class
    

      

    解决方法:在“com.bigdata.gulimall.gulimallgateway.GulimallGatewayApplication”中排除和数据源相关的配置

    @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
    

      

    重新启动

    访问:http://192.168.137.14:8848/nacos/#,查看到该服务已经注册到了Nacos中

  • 相关阅读:
    InjectAPC全部项目(Win32和Win64位)
    Codeforces Round #377 (Div. 2)
    Codeforces Canada Cup 2016
    UVa 1395 (最小生成树)
    空间表SpaceList
    线程中的临界区的应用
    【题解】狼和羊-C++
    【基础算法-树状数组】入门-C++
    【题解】在你窗外闪耀的星星-C++
    【题解】[NOIP模拟题]我要的幸福-C++
  • 原文地址:https://www.cnblogs.com/vincentmax/p/14373001.html
Copyright © 2011-2022 走看看