Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration "zuul.ratelimit.enable=false" failed to start the service #507

Closed
yiping-sun opened this issue Apr 2, 2022 · 3 comments
Closed
Labels
question stale This issue has been automatically marked as stale because it has not had recent activity

Comments

@yiping-sun
Copy link

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);
        }
    }
@github-actions
Copy link

github-actions bot commented Apr 2, 2022

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.

@marcosbarbero
Copy link
Owner

Hi @201708024103 can you share a repo where I can reproduce this behavior?

@github-actions
Copy link

github-actions bot commented Jun 2, 2022

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

@github-actions github-actions bot added the stale This issue has been automatically marked as stale because it has not had recent activity label Jun 2, 2022
@github-actions github-actions bot closed this as completed Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question stale This issue has been automatically marked as stale because it has not had recent activity
Projects
None yet
Development

No branches or pull requests

2 participants