Configuration "zuul.ratelimit.enable=false" failed to start the service
yiping-sun opened this issue · comments
Describe the question
Configuration zuul.ratelimit.enable=false Will it cause the service to fail to start
yml
zuul.ratelimit.enabled = false
error log
Description:
Parameter 0 of method rateLimitUtils in com.atta.zuul.ratelimit.RateLimitAutoConfiguration$RateLimitUtilsConfiguration required a bean of type 'com.atta.zuul.ratelimit.config.properties.RateLimitProperties' that could not be found.
Action:
Consider defining a bean of type 'com.atta.zuul.ratelimit.config.properties.RateLimitProperties' in your configuration.##
can't load bean
@Configuration
@ConditionalOnMissingBean(RateLimitUtils.class)
public static class RateLimitUtilsConfiguration {
@Bean
@ConditionalOnMissingClass("org.springframework.security.core.Authentication")
public RateLimitUtils rateLimitUtils(final RateLimitProperties rateLimitProperties) {
return new DefaultRateLimitUtils(rateLimitProperties);
}
}
@Configuration
@ConditionalOnClass(StringRedisTemplate.class)
@ConditionalOnMissingBean(RateLimiter.class)
@ConditionalOnProperty(prefix = PREFIX, name = "repository", havingValue = "REDIS")
public static class RedisConfiguration {
private static final String REDIS_TEMPLATE_BEAN_NAME = "rateLimiterRedisTemplate";
@Bean(REDIS_TEMPLATE_BEAN_NAME)
public StringRedisTemplate redisTemplate(final RedisConnectionFactory connectionFactory) {
return new StringRedisTemplate(connectionFactory);
}
@Bean
public RateLimiter redisRateLimiter(final RateLimiterErrorHandler rateLimiterErrorHandler,
@Qualifier(REDIS_TEMPLATE_BEAN_NAME) final StringRedisTemplate redisTemplate) {
return new RedisRateLimiter(rateLimiterErrorHandler, redisTemplate);
}
}
Additional context
It can be started normally after modification
@Configuration
@ConditionalOnMissingBean(RateLimitUtils.class)
//-----------------------------------------------------------------------------------------
@ConditionalOnProperty(prefix = PREFIX, name = "enabled", havingValue = "true")
//-----------------------------------------------------------------------------------------
public static class RateLimitUtilsConfiguration {
@Bean
@ConditionalOnMissingClass("org.springframework.security.core.Authentication")
public RateLimitUtils rateLimitUtils(final RateLimitProperties rateLimitProperties) {
return new DefaultRateLimitUtils(rateLimitProperties);
}
}
@Configuration
@ConditionalOnClass(StringRedisTemplate.class)
@ConditionalOnMissingBean(RateLimiter.class)
@ConditionalOnProperty(prefix = PREFIX, name = "repository", havingValue = "REDIS")
public static class RedisConfiguration {
private static final String REDIS_TEMPLATE_BEAN_NAME = "rateLimiterRedisTemplate";
@Bean(REDIS_TEMPLATE_BEAN_NAME)
//-----------------------------------------------------------------------------------------
@ConditionalOnProperty(prefix = PREFIX, name = "enabled", havingValue = "true")
//-----------------------------------------------------------------------------------------
public StringRedisTemplate redisTemplate(final RedisConnectionFactory connectionFactory) {
return new StringRedisTemplate(connectionFactory);
}
@Bean
//-----------------------------------------------------------------------------------------
@ConditionalOnProperty(prefix = PREFIX, name = "enabled", havingValue = "true")
//-----------------------------------------------------------------------------------------
public RateLimiter redisRateLimiter(final RateLimiterErrorHandler rateLimiterErrorHandler,
@Qualifier(REDIS_TEMPLATE_BEAN_NAME) final StringRedisTemplate redisTemplate) {
return new RedisRateLimiter(rateLimiterErrorHandler, redisTemplate);
}
}
Hello @201708024103, thanks for getting in touch, we will get back to you asap! If you have issues in the 1.x.x.RELEASE
line we recommend you to update to the latest version, unfortunately this line is not supported anymore.
Hi @201708024103 can you share a repo where I can reproduce this behavior?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 1 day