The difference between System.getenv() and System.getProperty()

System.getenv() gets environment variables.

System.getProperty() obtains the parameters set by the java startup script, such as java -jar -Dsrping.profiles.active=dev.

At this time, using System.getProperty("srping.profiles.active") returns dev.

 

When writing, it is recommended to have a priority concept, such as using System.getProperty() to get it first, if not, then get it from System.getenv(), if not, then perform corresponding business processing

Guess you like

Origin blog.csdn.net/kanyun123/article/details/117452659