【发布时间】:2020-03-11 11:28:30
【问题描述】:
在 CLI Linux 中我运行:
echo $HOSTNAME
并接收:
alex-HP-295-G1-SFF-Business-PC
我尝试在 java 中获取这个环境
ExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("systemEnvironment['HOSTNAME']");
String message = (String) expression.getValue();
System.out.println(message);
但收到以下异常:
SpelEvaluationException: EL1007E: Property or field 'systemEnvironment' cannot be found on null
我做错了什么?
【问题讨论】:
标签: java intellij-idea environment-variables hostname spring-el