웹 백엔드 개발/Spring Boot

[SpringBoot/오류 해결] lombok 작동 관련 문제 해결

iinana 2025. 4. 3. 07:47
728x90

jwt 토큰 관련 설정을 위한 코드를 작성하던 중 아래와 같은 오류를 마주했다.

Provider.java:71: error: cannot find symbol
                .setSigningKey(jwtProperties.getSecretKey())
                                            ^
  symbol:   method getSecretKey()
  location: variable jwtProperties of type JwtProperties

 

jwtProperties는 JwtProperties class의 object였는데, JwtProperties class는 아래와 같이 정의되어 있었다. 위 오류에서는 getSecretKey method에 관한 오류만 나와있지만, 사실 getter가 전부 동작하지 않았다. 

package com.survey.server.config.jwt;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Setter
@Getter
@Component
@ConfigurationProperties("jwt")
public class JwtProperties {
    private String issuer;
    private String secretKey;
    private String expiration;
}

 

jwt properties를 application.yml 파일에서 로드하는 것의 문제인지, 아니면 @Getter 어노테이션이 정상적으로 동작하지 않는 문제인지 알아보기 위해 getter method를 직접 작성해서 실행해 보았다. 그러니까 정상적으로 실행됐다. 즉, @Getter annotation이 정상적으로 실행되지 않아서 생긴 문제라는 것을 알 수 있다. 

 

그래서 build.gradle 파일을 확인해보니, lombok을 위한 dependency 하나가 빠져있었다. 추가해 주고 다시 실행하니 정상적으로 동작했다. 

annotationProcessor 'org.projectlombok:lombok'

728x90