Redis 주의사항 - @Qualifier 명시 지명으로, 생성자 우선순위 문제 오류 해결

devdo·2026년 2월 6일

SpringBoot

목록 보기
42/42
post-thumbnail
***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of constructor in datamatica.step.infrastructure.redis.adapter.RedisProgressNotificationAdapter required a single bean, but 2 were found:
	- progressRedisTemplate: defined by method 'progressRedisTemplate' in class path resource [datamatica/step/infrastructure/redis/config/RedisConfig.class]
	- stringRedisTemplate: defined by method 'stringRedisTemplate' in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.class]

This may be due to missing parameter name information

Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

✅ 해결법

@Slf4j
@Service
public class RedisTokenAdapter implements TokenRepository {

    private final RedisTemplate<String, String> redisTemplate;

    /**
     * 명시적 생성자
     * 
     * @param redisTemplate String 기반 RedisTemplate (토큰 저장용)
     */
    public RedisTokenAdapter(
            @Qualifier("stringRedisTemplate") RedisTemplate<String, String> redisTemplate
    ) {
        this.redisTemplate = redisTemplate;
    }

생성자 주입 @Qualifier 로 주입하면 해결!

profile
자바 스프링 백엔드 개발자입니다. 배운 것을 기록합니다.

0개의 댓글