File tree 2 files changed +14
-6
lines changed
src/shared/main/tv/codely/shared/infrastructure/config 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -8,5 +8,5 @@ gradle-app.setting
8
8
/var /log /*
9
9
! /var /log /.gitkeep
10
10
11
- / .env.local
12
- / .env. * .local
11
+ .env.local
12
+ .env. * .local
Original file line number Diff line number Diff line change 3
3
import io .github .cdimascio .dotenv .Dotenv ;
4
4
import org .springframework .context .annotation .Bean ;
5
5
import org .springframework .context .annotation .Configuration ;
6
+ import org .springframework .core .io .Resource ;
7
+ import org .springframework .core .io .ResourceLoader ;
6
8
7
9
@ Configuration
8
10
public class EnvironmentConfig {
11
+ ResourceLoader resourceLoader ;
12
+
13
+ public EnvironmentConfig (ResourceLoader resourceLoader ) {
14
+ this .resourceLoader = resourceLoader ;
15
+ }
16
+
9
17
@ Bean
10
18
public Dotenv dotenv () {
11
- Dotenv dotenv = Dotenv
19
+ Resource resource = resourceLoader .getResource ("classpath:/.env.local" );
20
+
21
+ return Dotenv
12
22
.configure ()
13
23
.directory ("/" )
14
- .filename (".env" )
24
+ .filename (resource . exists () ? ".env.local" : ".env" )
15
25
.load ();
16
-
17
- return dotenv ;
18
26
}
19
27
}
You can’t perform that action at this time.
0 commit comments