16-Nacos-快速入门

说是快速入门,实际就是服务注册[服务发现与eureka是一样的,不用修改代码]

  1. 添加依赖
  2. 父工程:

    <dependency>
                    <groupId>com.alibaba.cloud</groupId>
                    <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                    <version>2.2.5.RELEASE</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
    

    子工程:

            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
            </dependency>
    
    <!--        <dependency>-->
    <!--            <groupId>org.springframework.cloud</groupId>-->
    <!--            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>-->
    <!--        </dependency>-->
    
  3. 修改配置
  4. spring:
      datasource:
        url: jdbc:mysql://47.108.52.160:3306/cloud_order?useSSL=false
        username: root
        password: Mysql12345^
        driver-class-name: com.mysql.jdbc.Driver
      application:
        name: orderservice
      cloud:
        nacos:
          discovery:
            server-addr: localhost:8848
    #eureka:
    #  client:
    #    service-url:
    #      defaultZone: http://localhost:10086/eureka/
    

posted @ 2023-08-09 21:54  356a  阅读(4)  评论(0编辑  收藏  举报