11package com .back ;
22
3- import com .google .api . client . util . Value ;
3+ import com .google .auth . oauth2 . GoogleCredentials ;
44import jakarta .annotation .PostConstruct ;
5+ import org .springframework .beans .factory .annotation .Value ;
56import org .springframework .boot .SpringApplication ;
67import org .springframework .boot .autoconfigure .SpringBootApplication ;
78import org .springframework .cache .annotation .EnableCaching ;
89import org .springframework .data .jpa .repository .config .EnableJpaAuditing ;
910import org .springframework .scheduling .annotation .EnableAsync ;
1011
12+ import java .io .FileInputStream ;
13+ import java .nio .file .Path ;
14+ import java .nio .file .Paths ;
15+
1116@ SpringBootApplication
1217@ EnableJpaAuditing
1318@ EnableCaching
@@ -22,7 +27,18 @@ public static void main(String[] args) {
2227
2328 @ PostConstruct
2429 public void setGoogleCredentialsEnv () {
25- // Google SDK가 사용할 수 있도록 환경변수 세팅
26- System .setProperty ("GOOGLE_APPLICATION_CREDENTIALS" , googleCredentialsPath );
30+ Path path = Paths .get (googleCredentialsPath ).toAbsolutePath ();
31+ System .setProperty ("GOOGLE_APPLICATION_CREDENTIALS" , path .toString ());
32+ System .out .println ("*** Google credentials path set to: " + path );
33+
34+ try (FileInputStream serviceAccountStream = new FileInputStream (path .toFile ())) {
35+ GoogleCredentials credentials = GoogleCredentials .fromStream (serviceAccountStream );
36+
37+ System .out .println ("*** Google credentials loaded successfully!" );
38+ System .out .println ("*** Credentials type: " + credentials .getClass ().getSimpleName ());
39+ } catch (Exception e ) {
40+ System .err .println ("*** Failed to load Google credentials: " + e .getMessage ());
41+ }
2742 }
43+
2844}
0 commit comments