11package com .zaplink .ZapVerse ;
22
3+ import io .github .cdimascio .dotenv .Dotenv ;
34import org .springframework .boot .SpringApplication ;
45import org .springframework .boot .autoconfigure .SpringBootApplication ;
5- import io .github .cdimascio .dotenv .Dotenv ;
66
77@ SpringBootApplication
88public class ZapVerseApplication {
99
1010 public static void main (String [] args ) {
11- Dotenv dotenv = Dotenv . load () ;
11+ Dotenv dotenv = null ;
1212
13- // Set system properties so Spring Boot can resolve placeholders
14- System .setProperty ("SUPABASE_DB_URL" , dotenv .get ("SUPABASE_DB_URL" ));
15- System .setProperty ("SUPABASE_DB_USERNAME" , dotenv .get ("SUPABASE_DB_USERNAME" ));
16- System .setProperty ("SUPABASE_DB_PASSWORD" , dotenv .get ("SUPABASE_DB_PASSWORD" ));
13+ try {
14+ // Try loading from .env (local dev)
15+ dotenv = Dotenv .load ();
16+ System .out .println ("dotenv: Loaded environment variables from .env file." );
17+ } catch (Exception e ) {
18+ // If .env not found, use Azure environment variables
19+ System .out .println ("dotenv: .env file not found, using system environment variables." );
20+ }
21+
22+ // Set system properties (check dotenv first, then System.getenv)
23+ System .setProperty ("SUPABASE_DB_URL" , getenv (dotenv , "SUPABASE_DB_URL" ));
24+ System .setProperty ("SUPABASE_DB_USERNAME" , getenv (dotenv , "SUPABASE_DB_USERNAME" ));
25+ System .setProperty ("SUPABASE_DB_PASSWORD" , getenv (dotenv , "SUPABASE_DB_PASSWORD" ));
1726
1827 SpringApplication .run (ZapVerseApplication .class , args );
1928 }
2029
21- }
30+ private static String getenv (Dotenv dotenv , String key ) {
31+ if (dotenv != null && dotenv .get (key ) != null ) {
32+ return dotenv .get (key );
33+ }
34+ // Azure App Service variables
35+ return System .getenv (key );
36+ }
37+ }
0 commit comments