Skip to content

Commit e3eaac5

Browse files
authored
Create E20250707 Spring application properties.md
1 parent a07132c commit e3eaac5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
``` java
2+
public static void main(String[] args) {
3+
var app = new SpringApplication(DeviceApplication.class);
4+
var ctx = app.run(args);
5+
printActiveProperties(ctx.getEnvironment());
6+
}
7+
8+
private static void printActiveProperties(ConfigurableEnvironment env) {
9+
System.out.println("************************* ACTIVE APP PROPERTIES ******************************");
10+
env.getPropertySources().stream().filter(ps -> ps instanceof OriginTrackedMapPropertySource)
11+
.map(ps -> ((OriginTrackedMapPropertySource) ps).getSource().entrySet())
12+
.flatMap(it -> it.stream())
13+
.forEach(property -> System.out.println(property.getKey() + "=" + property.getValue()));
14+
}
15+
```

0 commit comments

Comments
 (0)