Skip to content

static 필드에 @Autowired 어노테이션 사용으로 인한 문제 발생 #166

@hyunsb

Description

@hyunsb

@Autowired 어노테이션은 스프링 컨텍스트 내에서 관리되는 Bean을 주입하는 기능을 수행함.
정적 필드는 클래스 레벨에서 공유되며, 인스턴스와는 별도로 생성됨.

스프링은 인스턴스 생성 시에 Bean 주입을 수행하는데, 정적 필드는 클래스 레벨에서 Bean 생성과 무관함.
따라서 정적 필드에 @Autowired 어노테이션을 사용하면, 스프링이 해당 필드에 의존성을 주입하지 않을 수 있음.

따라서 정적 필드에 작성된 @Autowired 어노테이션을 제거하고자 함.

정적 필드에 @Autowired어노테이션이 사용된 클래스

  • AESEncryption
    @Value("${aes-key}")
    private static String AES_KEY;
  • JwtTokenProvider
    @Value("${secret-key}")
    private static String secretKey;

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcore코어 모듈 기능

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions