File tree 5 files changed +34
-1
lines changed
java/com/github/nramc/dev/journey/api
5 files changed +34
-1
lines changed Original file line number Diff line number Diff line change
1
+ package com .github .nramc .dev .journey .api .config ;
2
+
3
+ import org .springframework .boot .context .properties .EnableConfigurationProperties ;
4
+ import org .springframework .context .annotation .Configuration ;
5
+
6
+ @ Configuration
7
+ @ EnableConfigurationProperties ({ApplicationProperties .class })
8
+ public class ApplicationContextConfig {
9
+
10
+ }
Original file line number Diff line number Diff line change
1
+ package com .github .nramc .dev .journey .api .config ;
2
+
3
+ import org .springframework .boot .context .properties .ConfigurationProperties ;
4
+
5
+ @ ConfigurationProperties (prefix = "app" )
6
+ public record ApplicationProperties (
7
+ String name ,
8
+ String version ) {
9
+ }
Original file line number Diff line number Diff line change 1
1
package com .github .nramc .dev .journey .api .web .resources .mvc .home ;
2
2
3
+ import com .github .nramc .dev .journey .api .config .ApplicationProperties ;
4
+ import lombok .RequiredArgsConstructor ;
3
5
import org .springframework .http .MediaType ;
4
6
import org .springframework .stereotype .Controller ;
5
7
import org .springframework .ui .Model ;
6
8
import org .springframework .web .bind .annotation .GetMapping ;
7
9
8
10
@ Controller
11
+ @ RequiredArgsConstructor
9
12
public class HomeResource {
13
+ private final ApplicationProperties applicationProperties ;
10
14
11
15
@ GetMapping (value = "/" , produces = MediaType .TEXT_HTML_VALUE )
12
16
public String home (Model model ) {
17
+ model .addAttribute ("applicationProperties" , applicationProperties );
13
18
return "home" ;
14
19
}
15
20
Original file line number Diff line number Diff line change 1
1
2
+ spring :
3
+ application :
4
+ name : ${app.name}
5
+
6
+ app :
7
+ name : Journey API
8
+ version : ' @project.version@'
Original file line number Diff line number Diff line change 5
5
< title > Hello World</ title >
6
6
</ head >
7
7
< body >
8
- < p > Hello World..!</ p >
8
+ < p > Hello World..!</ p >
9
+ < p > < span th:text ="${applicationProperties.name()} "> </ span > :< span th:text ="${applicationProperties.version()} "> </ span >
10
+ </ p >
9
11
</ body >
10
12
</ html >
You can’t perform that action at this time.
0 commit comments