Closed fuhongtao closed 6 years ago
What was the value you added to the property?
i try zuul.ratelimit.repository=IN_MEMORY and zuul.ratelimit.repository=REDIS . all two make mistakes
Do you have a sample project that I can check?
I'll email you
Ok, thank you
Thank you for your support. For some reason, I may not send the item to you by mail. Please paste some files of my project for reference.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Dalston.SR4</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.maihaoche</groupId>
<artifactId>spring-boot-starter-rocketmq</artifactId>
<version>0.0.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
<dependency>
<groupId>com.marcosbarbero.cloud</groupId>
<artifactId>spring-cloud-zuul-ratelimit</artifactId>
<version>1.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
zuul.ribbon.eager-load.enabled= true
zuul.sensitiveHeaders= zuul.add-host-headers=true
zuul.routes.local.path=/local/** zuul.routes.local.url=forward:/local
zuul.ratelimit.enabled=true
zuul.ratelimit.policies.local.limit=3 zuul.ratelimit.policies.local.refresh-interval=60 zuul.ratelimit.policies.local.type=origin zuul.ratelimit.policies.yd-admin.limit=30 zuul.ratelimit.policies.yd-admin.refresh-interval=60 zuul.ratelimit.policies.yd-admin.type=origin
When I add the following code, everything is OK
public static void main(String[] args) {
// RateLimitAutoConfiguration a;
SpringApplication.run(YdGatewayApplication.class, args);
}
@Bean("rateLimiterRedisTemplate")
public StringRedisTemplate redisTemplate(final RedisConnectionFactory connectionFactory) {
return new StringRedisTemplate(connectionFactory);
}
@Bean
public RateLimiter redisRateLimiter(@Qualifier("rateLimiterRedisTemplate") final RedisTemplate redisTemplate) {
return new RedisRateLimiter(redisTemplate);
}
I’ll play with your configuration and let you know once I have a solution
@fuhongtao can you take a look at this sample?
i try the sample,it's not work.
I'll double check it
use version 1.3.4.RELEASE add property zuul.ratelimit.repository Parameter 0 of method rateLimiterPreFilter in com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.RateLimitAutoConfiguration required a bean of type 'com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.RateLimiter' that could not be found.