无法在 spring-integration 4.1.x 中将 String 值转换为 ExpressionEvaluatingRequestHandlerAdvice 的表达式

2024-01-11

我无法让 ExpressionEvaluatingRequestHandlerAdvice 类在 Spring Integration 4.1.x 中工作。以下表达式建议上下文 XML 片段会产生一个转换错误,指出 Spring 无法将 onSuccessExpression 属性从字符串转换为表达式。在 Spring Integration 4.1.0-RELEASE 之前,setOnSuccessExpression() 方法仅接受字符串,现在它被重载以接受字符串或表达式。

<sftp:outbound-channel-adapter channel="outboundChannel"
    session-factory="sftpCachingSessionFactory" remote-directory="${sftp.remote.file.location.path}"
    temporary-file-suffix=".tmp">
    <sftp:request-handler-advice-chain>
        <bean
            class="org.springframework.integration.handler.advice.RequestHandlerRetryAdvice">
            <property name="retryTemplate" ref="defaultRetryTemplate" />
        </bean>
        <bean
            class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
            <property name="onSuccessExpression" value="headers.ID" />
            <property name="successChannel" ref="outboundSuccessChannel" />
        </bean>
    </sftp:request-handler-advice-chain>
</sftp:outbound-channel-adapter>

以下是显示的错误:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.file.config.FileWritingMessageHandlerFactoryBean#0': Cannot resolve reference to bean 'org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice#7d12855' while setting bean property 'adviceChain' with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice#7d12855' defined in class path resource [file-transfer-service-file-endpoint-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.expression.Expression' for property 'onSuccessExpression'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.expression.Expression] for property 'onSuccessExpression': no matching editors or conversion strategy found
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1469)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:743)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at pmd.common.spring.SpringServiceContextLoader.main(SpringServiceContextLoader.java:63)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice#7d12855' defined in class path resource [file-transfer-service-file-endpoint-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.expression.Expression' for property 'onSuccessExpression'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.expression.Expression] for property 'onSuccessExpression': no matching editors or conversion strategy found
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
    ... 15 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.expression.Expression' for property 'onSuccessExpression'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.expression.Expression] for property 'onSuccessExpression': no matching editors or conversion strategy found
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:475)
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:511)
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:505)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1515)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1474)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    ... 21 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.expression.Expression] for property 'onSuccessExpression': no matching editors or conversion strategy found
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:287)
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:460)
    ... 27 more

我的问题是我认为我的 onSuccessExpression 不应该被转换,setOnSuccessExpression() 方法上有一个字符串设置器。我是否有修复,或者 Spring Int 是否造成了错误?


这是一个错误;我们添加了第二组 setter 来支持 DSL(因此您可以注入字符串或表达式)。

问题是这违反了 JavaBean 定义(2 个具有不同参数类型的 setter),因此 Spring 不知道选择哪一个。我们需要更改方法名称。

不幸的是,Spring 调用哪个方法是不确定的。

与此同时,你可以尝试用这个来解决这个问题......

<bean id="success" class="org.springframework.integration.config.ExpressionFactoryBean">
    <constructor-arg value="headers.ID" />
</bean>

and...

<property name="onSuccessExpression" ref="success" />

但不幸的是,调用哪个方法是不确定的;在我的环境中,您的代码可以工作,因为选择了该方法的字符串版本。

因此,您可能必须将建议作为@Bean如果您在多个环境中运行,则作为解决方法。

我开了一个JIRA 问题 https://jira.spring.io/browse/INT-3595。我们将很快在版本中修复该问题。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法在 spring-integration 4.1.x 中将 String 值转换为 ExpressionEvaluatingRequestHandlerAdvice 的表达式 的相关文章

随机推荐

  • TFS 2018 Update 2 IIS 网站部署已弃用或缺失

    将 TFS 更新到更新 2 后 在 CI 构建任务中 IIS Web 应用程序部署 被标记为 已弃用 这个任务的替代品是什么 Also in the CD in the after adding IIS Website Deployment
  • Django 无效的块标签:endelse 和 ifequal

    我想使用 djangoifequal and else判断变量是否等于的标签80 or 22 所以 这是代码 if firewalls thead tr th IP address th th Function th tr thead en
  • O(n) 算法找出出现次数超过 n/2 次的元素

    在一次采访中 有人要求我提供一个 O n 算法来打印在数组中出现超过 n 2 次的元素 如果存在这样的元素 n 是数组的大小 我不知道如何做到这一点 有人可以帮忙吗 这是博耶的投票算法 http www cs utexas edu moor
  • 按钮高度不一致(跨浏览器)

    我在设置按钮的高度时遇到问题 基本上我无法跨浏览器使用它 对于 Firefox 它高于normal 没有任何理由 这是一个屏幕截图 Firefox Safari 和 Opera 按此顺序 这里是代码 http jsfiddle net TM
  • 在 iOS 中绘制矩形

    我的应用程序的目标是让用户能够通过向左和向右滑动 iPhone 屏幕来对不同的日程安排选项进行排序 当用户对这些不同的调度选项进行排序时 我将如何绘制和删除矩形 我有一个 UIViewController h UIViewControlle
  • 通过文档文字 SOAP 发送 Base64 图像的替代方案

    我目前正在修改业务应用程序的文档文字 SOAP 服务 该应用程序前后传输有关客户的数据 刚刚确定了传输扫描文档图像的新要求 我遇到的问题是我使用的专有语言不支持 SOAP 附件 传输的图像可以是最大 32KB 的任何图像 我能想到的唯一解决
  • 获取产品的自定义选项值 magento 2

    我的产品有两个自定义选项 颜色和尺寸都是下拉菜单 在产品详细信息页面中 我必须显示该产品的所有可用颜色 我尝试了以下代码并且它有效 但它返回所有颜色和大小的值 但我只需要颜色值 那就是我想按颜色选择自定义选项 product block g
  • 在Windows中,2<&1和2>&1有什么区别?

    本页中的示例和解释让我感到困惑 http www microsoft com resources documentation windows xp all proddocs en us redirection mspx mfr true h
  • 等待 Kotlin 协程在 onCreateView() 中完成

    我有一个初始化块onCreateView 其中一些变量是从 SharedPreferences DB 或 Network 当前从 SharedPreferences 分配的 我想用这些值更新视图onViewCreated 但它们在协程之前更
  • 合并所有两个表但列数不同

    select count as total FROM SELECT FROM database1 orders WHERE number LIKE 11111111111111111 UNION ALL SELECT FROMdatabas
  • 信号会通过哪些方式干扰管道通信?

    我对信号一无所知 对管道也只有一点了解 从评论来看zdim s在这里回答 https stackoverflow com questions 48558093看来信号可能会干扰父进程和子进程之间的管道通信 有人告诉我 如果你使用IO Sel
  • 错误:(24, 11) 无法解析:com.android.support:appcompat-v7:8.0.+

    请帮助解决这个错误 因为这是我的第一个 Android 项目 摇篮同步 应用插件 com android application android compileSdkVersion 8 buildToolsVersion 23 0 2 de
  • 什么是对象切片?

    在 C 中 什么是对象切片以及它何时发生 切片 是将派生类的对象分配给基类的实例 从而丢失部分信息 其中一些信息被 切片 掉 例如 class A int foo class B public A int bar 所以一个类型的对象B有两个
  • Bootstrap 委托弹出内容回调触发两次

    我正在使用 Twitter Bootstrap 2 3 2 并且我正在注册一个弹出窗口 每当带有选择器的 td 悬停在上面时就会打开 但是我注意到在控制台中内容回调被触发两次 有没有办法防止这种情况发生 table data popover
  • Caffe 中的欧几里得损失层

    我目前正在尝试在 caffe 中实现我自己的损失层 在尝试这样做的同时 我使用其他层作为参考 然而 让我困惑的一件事是使用top 0 gt cpu diff in Backward cpu 我将使用EuclideanLossLayer作为参
  • ruby中的递归哈希转换函数

    我有以下响应模式的 swagger openAPI 定义 h type gt object properties gt books gt type gt array items gt type gt object properties gt
  • Heroku 无法验证 mongolab

    前两天已经修正了 昨天我对 heroku 做了一些更改 应用程序崩溃了 我发现heroku logs that app bundle gems ruby 1 9 1 gems mongo 1 4 0 lib mongo db rb 137
  • 客户多地址和默认地址的Mysql数据库设计

    我正在使用 Mysql 和 INNODB 引擎创建电子商务的数据库结构 Point 1 要为客户创建多个地址 我有这个表 我以正确的方式做吗 我应该如何存储默认地址 在哪个表中 Point 2 我有另一个名为 供应商 的表 我应该将其连接到
  • 在 Django 上的 Ajax 中重新加载整个页面?

    我正在使用 ajax 来执行该函数并检查该值是否已存在于数据库中 如果数据已经存在 我会显示 jQuery 对话框 该对话框工作正常 但如果该值尚不存在 我不想显示弹出窗口并刷新整个页面 这是我的 AJAX 函数 function copy
  • 无法在 spring-integration 4.1.x 中将 String 值转换为 ExpressionEvaluatingRequestHandlerAdvice 的表达式

    我无法让 ExpressionEvaluatingRequestHandlerAdvice 类在 Spring Integration 4 1 x 中工作 以下表达式建议上下文 XML 片段会产生一个转换错误 指出 Spring 无法将 o