The error message 'Could not autowire. There is more than one bean of 'RedisUtils' type' suggests that your Spring Boot application context has multiple beans of the same type, 'RedisUtils'. This typically arises from having multiple configurations or components defining the 'RedisUtils' bean.

Here are the common solutions to resolve this conflict:

  1. Remove or Fix Duplicate Bean Definitions: Thoroughly examine your configuration classes. Ensure that there is only one definition for the 'RedisUtils' bean. If multiple definitions exist, remove the duplicates or verify their configuration is correct.

  2. Utilize the @Qualifier Annotation: If you need to explicitly specify which bean to use from multiple beans of the same type, employ the @Qualifier annotation. Add it to the injection point and provide the desired bean name. For example:

@Autowired
@Qualifier('redisUtils')
private RedisUtils redisUtils;

In this scenario, the bean named 'redisUtils' will be injected.

  1. Use the @Primary Annotation: When you have multiple beans of the same type and want one to be the default choice for autowiring, use the @Primary annotation. Apply it to the bean definition you intend as the primary choice. For instance:
@Bean
@Primary
public RedisUtils redisUtils() {
    // bean definition
}

With the @Primary annotation, this bean will be selected for autowiring when multiple beans of the same type are available.

Choose the solution that best fits your application context and specific requirements.

Spring Boot: Resolve 'Could not autowire. There is more than one bean of 'RedisUtils' type' Error