【问题标题】:Spring Cloud Netflix Zuul. SQLSyntaxErrorException: Table 'rate' doesn't existSpring Cloud Netflix Zuul。 SQLSyntaxErrorException: 表 'rate' 不存在
【发布时间】:2019-08-29 10:09:51
【问题描述】:

我正在尝试使用 JPA 存储库在我的 Spring Cloud Netflix Zuul 中配置 速率限制。 但是一开始我收到了这个异常:

java.sql.SQLSyntaxErrorException: 表 'kirillbq_bl_acc.rate' 没有 存在

我的application.yaml

zuul:
  routes:
    my-service:
      path: /
  ratelimit:
    enabled: true
    repository: JPA
    policy-list:
      my-service:
        - limit: 2
          refresh-interval: 60
          type:
            - origin
  strip-prefix: true

我在一个项目中也有一个 spring-boot-starter-data-jpa 依赖项。

我假设 Zuul 需要一个 'Rate' 表来存储有关请求的信息,但是我找不到有关此类表结构的任何信息。应该是什么?

【问题讨论】:

    标签: java spring spring-boot netflix-zuul


    【解决方案1】:

    我找到了这个信息:https://www.programcreek.com/java-api-examples/?code=marcosbarbero/spring-cloud-zuul-ratelimit/spring-cloud-zuul-ratelimit-master/spring-cloud-zuul-ratelimit-core/src/main/java/com/marcosbarbero/cloud/autoconfigure/zuul/ratelimit/RateLimitAutoConfiguration.java#

    config 文件夹中有 Rate.java 类,其结构为“Rate”表:

    @Entity
    public class Rate {
    
        @Id
        private String key;
        private Long remaining;
        private Long remainingQuota;
        private Long reset;
        @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss")
        private Date expiration;
    
        // constructor, getters and setters 
    }
    

    创建此表后,一切正常。 Zuul 将有关请求的信息保存在此表中。

    【讨论】:

      猜你喜欢
      • 2016-09-30
      • 2020-04-15
      • 2018-08-25
      • 2021-09-07
      • 1970-01-01
      • 2020-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多