H.Ç.T
H.Ç.T

Reputation: 3569

How can I inject OS hostname value in Spring Boot?

Is it possible to do something like that?

@Value("${xxx.hostname}")
private String hostname;

Is it also possible to get any other System Environment Property like that?

Upvotes: 0

Views: 3620

Answers (1)

Jonathan Schoreels
Jonathan Schoreels

Reputation: 1720

Spring Boot automatically allow you to take environment variable.

You can just do @Value("${HOSTNAME}") (if HOSTNAME is defined ofc)

You can also use your application.properties to have something like :

xxx.hostname = ${HOSTNAME}

Upvotes: 2

Related Questions