Jvm options

SET

Jvm argument

Jvm arguments are begun with ‘-D’.

1
java -jar -Dfoo heumsi-springboot.jar

Application argument

Application arguments are begun with ‘—‘.

1
java -jar --bar heumsi-sprinboot.jar

GET

application.properties

the arguments can be stored at ‘application.properties’ file as key-value type. and It can is approached using @Value in Java code.

1
2
3
4
5
6
// set value in application.properties
heumsi.name = heumsi

// get value in *.java
@Value("${heumsi.name}")
private String name;

Environment

You can approach the arguments without ‘.properties’ file using Environment object.

1
2
3
4
@Autowired
Environment environment;

private String name = environment.getProperty("heumsi.name");
Share