File tree 2 files changed +40
-0
lines changed
src/main/java/cn/netbuffer/springboot/demo/controller
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -58,3 +58,6 @@ GET http://localhost:9100/param/getRemotePort
58
58
59
59
### /param/getLocalPort
60
60
GET http://localhost:9100/param/getLocalPort
61
+
62
+ ### /application/info
63
+ GET http://localhost:9100/application/info
Original file line number Diff line number Diff line change
1
+ package cn .netbuffer .springboot .demo .controller ;
2
+
3
+ import io .micrometer .core .instrument .util .IOUtils ;
4
+ import lombok .extern .slf4j .Slf4j ;
5
+ import org .springframework .context .ApplicationContext ;
6
+ import org .springframework .web .bind .annotation .GetMapping ;
7
+ import org .springframework .web .bind .annotation .RequestMapping ;
8
+ import org .springframework .web .bind .annotation .RestController ;
9
+ import javax .annotation .Resource ;
10
+ import java .io .IOException ;
11
+
12
+ @ Slf4j
13
+ @ RestController
14
+ @ RequestMapping ("/application/info" )
15
+ public class ApplicationInfoController {
16
+
17
+ @ Resource
18
+ private ApplicationContext applicationContext ;
19
+ private String gitProperties = "git.properties" ;
20
+
21
+ @ GetMapping
22
+ public String info () {
23
+ org .springframework .core .io .Resource resource = applicationContext .getResource ("classpath:" +gitProperties );
24
+ log .debug ("check {} isExist={}" , gitProperties , resource .exists ());
25
+ String info = "nothing" ;
26
+ if (resource .exists ()) {
27
+ try {
28
+ info = IOUtils .toString (resource .getInputStream ());
29
+ } catch (IOException e ) {
30
+ info = "error info" ;
31
+ log .error ("read {} error" , gitProperties , e );
32
+ }
33
+ }
34
+ return info ;
35
+ }
36
+
37
+ }
You can’t perform that action at this time.
0 commit comments