【发布时间】:2019-02-26 00:34:58
【问题描述】:
谁能告诉我为什么这不起作用:
@Test
public void should_parse_json() {
Expression expression = new SpelExpressionParser().parseExpression("#jsonPath(get('JsonData'), '$.someData')");
Map<String, Object> data = new HashMap<>();
data.put("JsonData", "{\"someData\": 100}");
StandardEvaluationContext context = new StandardEvaluationContext(data);
context.addPropertyAccessor(new JsonPropertyAccessor());
assertThat(expression.getValue(context, Object.class)).isEqualTo(100);
}
我收到错误“org.springframework.expression.spel.SpelEvaluationException: EL1006E: Function 'jsonPath' could not be found”
我在类路径中有以下 jar:
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</dependency>
SPEL 文档对我没有帮助。
【问题讨论】:
标签: spring spring-integration jsonpath spring-el