🤍 전 강의 25% 할인 중 🤍

2024년 상반기를 돌아보고 하반기에도 함께 성장해요!
인프런이 준비한 25% 할인 받으러 가기 >>

  • 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

Slf4j log 관련 오류

22.02.24 13:45 작성 조회수 292

0

[질문 템플릿]
1. 강의 내용과 관련된 질문인가요? (예)
2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)
3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)

[질문 내용]
 
안녕하세요 영한님 항상 좋은 강의 감사드립니다.
 
templateMethodV2 를 작성하는 과정에서 오류가 발생했습니다.
'log' has private access in 'com.example.advance.template.code.AbstractTemplate'
위와 같은 컴파일 오류인데요
 
제 코드는 아래와 같습니다
package com.example.advance.template;

import com.example.advance.template.code.AbstractTemplate;
import com.example.advance.template.code.SubclassLogic1;
import com.example.advance.template.code.SubclassLogic2;
import org.junit.jupiter.api.Test;

public class TemplateMethodTest {

@Test
void templateMethodV1() {
AbstractTemplate template1 = new SubclassLogic1();
template1.execute();

AbstractTemplate template2 = new SubclassLogic2();
template2.execute();
}

@Test
void templateMethodV2() {
AbstractTemplate template = new AbstractTemplate() {
@Override
protected void call() {
log.info("비즈니스 로직1 실행");
}
};
log.info("클래스 이름1={}", template.getClass());
template.execute();

AbstractTemplate template2 = new AbstractTemplate() {
@Override
protected void call() {
log.info("비즈니스 로직2 실행");
}
};
log.info("클래스 이름2={}", template2.getClass());
template2.execute();
}
}


 

 

참고로 intellij 롬복 플러그인 설치했고, build.gradle 에서 아래 코드도 추가되어 있는 상태입니다.

testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'

 

답변 1

답변을 작성해보세요.

2

David님의 프로필

David

2022.02.24

안녕하세요. Jiwon님, 공식 서포터즈 David입니다.

클래스 상단에 @Slf4j 애노테이션이 빠진 것 같습니다. 추가하고 다시 시도해보시겠어요?

감사합니다.

Jiwon님의 프로필

Jiwon

질문자

2022.02.24

덕분에 해결했습니다 빠른 답변 감사드립니다!

채널톡 아이콘