...

Spring Boot에서 gcp storage 사용 시 storage에 의존성 주입이 되지 않은 경우 본문

백엔드

Spring Boot에서 gcp storage 사용 시 storage에 의존성 주입이 되지 않은 경우

gi2 2023. 7. 26. 18:40
@Configuration
public class GoogleCloudStorageConfig {
    @Bean
    public Storage storage() throws IOException {

        ClassPathResource resource = new ClassPathResource("key.json");
        GoogleCredentials credentials = GoogleCredentials.fromStream(resource.getInputStream());
        String projectId = "project id";
        return StorageOptions.newBuilder()
                .setProjectId(projectId)
                .setCredentials(credentials)
                .build()
                .getService();
    }
}

위와 같은 Configuration 파일을 만들어 storage 의존성을 직접 주입해준다........

'백엔드' 카테고리의 다른 글

RDBMS (MySQL vs PostgreSQL) 비교  (1) 2024.12.01
windows powershell에서 docker login 실행 안됨  (0) 2023.08.18
Spring 3.x에 Swagger 적용하기  (0) 2023.07.25
Spring CORS 에러 해결  (0) 2023.07.25
Ec2 서버 배포 방법 정리  (0) 2022.07.12
Comments