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
Imagine you have the following application.properties:
db.minimum.idle=12
db.pool.size=10
Then you should just do something like:
@Value("${db.pool.size}")
private Integer dbPoolSize;
@Value("${db.minimum.idle}")
private Integer dbMinimumIdle;
You do not have to create a new integer, that is automacally done by spring
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With