File tree Expand file tree Collapse file tree
src/main/java/com/example/spring_boot_project Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com .example .spring_boot_project ;
22
3- import io .github .cdimascio .dotenv .Dotenv ;
43import org .springframework .boot .SpringApplication ;
54import org .springframework .boot .autoconfigure .SpringBootApplication ;
65
6+ import com .example .spring_boot_project .config .DotenvInitializer ;
7+
78@ SpringBootApplication
89public class SpringBootProjectApplication {
910 public static void main (String [] args ) {
10- Dotenv dotenv = Dotenv .configure ()
11- .ignoreIfMissing ()
12- .load ();
13-
14- setSystemPropertyIfPresent (dotenv , "ADMIN_USERNAME" );
15- setSystemPropertyIfPresent (dotenv , "ADMIN_PASSWORD" );
16- setSystemPropertyIfPresent (dotenv , "JWT_SECRET_KEY" );
17- setSystemPropertyIfPresent (dotenv , "SERVER_COMPRESSION_MIN_RESPONSE_SIZE" );
18-
19- SpringApplication .run (SpringBootProjectApplication .class , args );
20- }
21-
22- /**
23- * verify system property if present
24- *
25- * @param dotenv
26- * @param key
27- * @return void
28- */
29- private static void setSystemPropertyIfPresent (Dotenv dotenv , String key ) {
30- String value = dotenv .get (key );
31- if (value != null ) {
32- System .setProperty (key , value );
33- }
11+ SpringApplication app = new SpringApplication (SpringBootProjectApplication .class );
12+ app .addInitializers (new DotenvInitializer ());
13+ app .run (args );
3414 }
3515}
You can’t perform that action at this time.
0 commit comments