0
点赞
收藏
分享

微信扫一扫

DataGrip远程连接Spark-sql,和使用beeline命令来连接hive

phpworkerman 2024-11-03 阅读 9

1. 配置管理

在这里插入图片描述
在这里插入图片描述
实现配置管理热更新。

2. 配置编写

在这里插入图片描述
在这里插入图片描述

3. 微服务拉取Nacos配置

在这里插入图片描述

  1. 引入加载bootstrap.yaml的依赖。
  <!--nacos配置管理-->
  <dependency>
      <groupId>com.alibaba.cloud</groupId>
      <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
  </dependency>
  <!--读取bootstrap文件-->
  <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-bootstrap</artifactId>
  </dependency>
  1. bootstrap.yaml
spring:
  application:
    name: cart-service
  profiles:
    active: dev
  cloud:
    nacos:
      server-addr: 139.224.66.95:8848
      config:
        file-extension: yaml
        shared-configs:
          - data-id: shared-jdbc.yaml
          - data-id: shared-log.yaml
          - data-id: shared-swagger.yaml
  1. application.yaml
server:
  port: 8084
feign:
  okhttp:
    enabled: true # 开启OKHttp功能
hm:
  db:
    host: localhost
    database: hm-cart
  swagger:
    title: "购物车管理接口"
    package: com.hmall.cart.controller

4. 配置热更新

当修改配置文件中的配置时,微服务无需重启即可使配置生效。

  1. 配置类
@Data
@Component
@ConfigurationProperties(prefix = "hm.cart")
public class CartProperties {
    private Integer maxItems;
}
  1. nacos配置文件
    在这里插入图片描述
举报

相关推荐

0 条评论