我正在使用Spring Boot示例从属性文件中读取以下内容。
sub.region.data={\
AF: {'subRegionCd' : '34', 'subRegionName' : 'Southern Asia', 'subRegionDesc', '', 'status' : 'A'} \
}
我在下面使用过,但是没有用
@Value("#{${sub.region.data}}")
private Map<String, SubRegion> subRegionsMap;
SubRegion.java
public class SubRegion {
private String subRegionCd;
private String subRegionName;
private String subRegionDesc;
private String subRegionStatus;
}
我遇到错误
Caused by: org.springframework.expression.spel.SpelParseException: Expression [{AF: {'subRegionCd' : '34', 'subRegionName' : 'Southern Asia', 'subRegionDesc', '', 'status' : 'A'} }] @78: EL1043E: Unexpected token. Expected 'colon(:)' but was 'comma(,)'
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.internalException(InternalSpelExpressionParser.java:1044) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatToken(InternalSpelExpressionParser.java:926) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.maybeEatInlineListOrMap(InternalSpelExpressionParser.java:670) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatStartNode(InternalSpelExpressionParser.java:521) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatPrimaryExpression(InternalSpelExpressionParser.java:351) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatUnaryExpression(InternalSpelExpressionParser.java:345) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatPowerIncDecExpression(InternalSpelExpressionParser.java:304) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatProductExpression(InternalSpelExpressionParser.java:282) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatSumExpression(InternalSpelExpressionParser.java:264) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatRelationalExpression(InternalSpelExpressionParser.java:218) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatLogicalAndExpression(InternalSpelExpressionParser.java:205) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatLogicalOrExpression(InternalSpelExpressionParser.java:192) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatExpression(InternalSpelExpressionParser.java:153) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.maybeEatInlineListOrMap(InternalSpelExpressionParser.java:667) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatStartNode(InternalSpelExpressionParser.java:521) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatPrimaryExpression(InternalSpelExpressionParser.java:351) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatUnaryExpression(InternalSpelExpressionParser.java:345) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatPowerIncDecExpression(InternalSpelExpressionParser.java:304) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatProductExpression(InternalSpelExpressionParser.java:282) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatSumExpression(InternalSpelExpressionParser.java:264) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatRelationalExpression(InternalSpelExpressionParser.java:218) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatLogicalAndExpression(InternalSpelExpressionParser.java:205) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatLogicalOrExpression(InternalSpelExpressionParser.java:192) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatExpression(InternalSpelExpressionParser.java:153) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.doParseExpression(InternalSpelExpressionParser.java:131) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:61) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:33) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.common.TemplateAwareExpressionParser.parseExpressions(TemplateAwareExpressionParser.java:121) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.common.TemplateAwareExpressionParser.parseTemplate(TemplateAwareExpressionParser.java:62) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.expression.common.TemplateAwareExpressionParser.parseExpression(TemplateAwareExpressionParser.java:49) ~[spring-expression-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:142) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
... 58 common frames omitted
[您似乎在'subRegionDesc',
之后犯了一个错误,我认为您的意思是使用冒号,而不是此处的逗号