I have a Spring Boot config file with this values:
@Value("#{new Integer('${db.pool.size}')}")
private Integer dbPoolSize;
@Value("#{new Integer('${db.minimum.idle}')}")
private Integer dbMinimumIdle;
But when I start the application I got this error:
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1003E: A problem occurred whilst attempting to construct an object of type 'Integer' using arguments '(java.lang.String)'
at org.springframework.expression.spel.ast.ConstructorReference.createNewInstance(ConstructorReference.java:168) ~[spring-expression-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.expression.spel.ast.ConstructorReference.getValueInternal(ConstructorReference.java:98) ~[spring-expression-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:120) ~[spring-expression-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:242) ~[spring-expression-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:161) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
... 42 common frames omitted
Just use:
@Value("${db.minimum.idle}")
private Integer dbMinimumIdle;
No need to explicitly instantiate new integer using spel.