java - Spring EL 无法在 xml 配置文件的 Integer 属性中解析
问题描述
我正在尝试在 XML 配置中使用 Spring EL:Creating a task executor with queue-capacity from an existing beans ConfigProp。
<task:executor id="executorWithPoolSizeRange"
pool-size="#{ConfigProp.async.corePoolSize}-#{ConfigProp.async.maxPoolSize}"
queue-capacity="#{ConfigProp.async.queueCapacity}"/>
从 Intellij IDEA 中可以看出,pool-size
可以正确解析,但不能为queue-capacity
整数类型。
IDEA 投诉信息
Cannot convert string #{ConfigProp.async.queueCapacity} to target class java.lang.Integer"
使用 Tomcat 运行时的执行日志
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 129 in XML document from ServletContext resource [/WEB-INF/dispatcher-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 129; columnNumber: 69; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'task:executor'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:402) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
我做错了什么还是 SpringEL 不支持?
解决方案
我可以手动创建一个ThreadPoolTaskExecutor
bean,但它仍然无法回答我的问题。
<beans:bean id="executorWithPoolSizeRange" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<beans:property name="corePoolSize" value="#{ConfigProp.async.corePoolSize}" />
<beans:property name="maxPoolSize" value="#{ConfigProp.async.maxPoolSize}" />
<beans:property name="queueCapacity" value="#{ConfigProp.async.queueCapacity}" />
</beans:bean>
推荐阅读
- python - 如何让令牌在一段时间后过期?(没有 jwt)
- android-studio - 无法在 Android Studio 3.5.1 中创建语言环境 strings.xml
- xml - XSLT拆分字符串,将它们存储在变量中并输出它们
- javascript - Angular 8 - 处理 http 返回的 observable 时的管道问题
- object - 在处理中导入 .dae 文件
- spring - 如何在 Spring 中用另一个 RestController 扩展一个 RestController 的路由?
- c# - Neo4j Cypher 具有属性的最短路径
- sql - MariaDB 更新语句的正确语法
- html - CSS - Div 焦点更改蓝色边框突出显示颜色
- tensorflow - 计算多个张量的损失值