gpt4 book ai didi

spring - SFTP 出站网关不工作

转载 作者:行者123 更新时间:2023-12-05 04:15:33 34 4
gpt4 key购买 nike

我正在尝试实现 SFTP 出站网关并收到以下异常。下载到本地目录后,我想将文件从一个位置移动到另一个位置。我是这个领域的新手。有人可以帮帮我吗。提前致谢。

异常跟踪日志:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.sftp.gateway.SftpOutboundGateway#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.integration.sftp.gateway.SftpOutboundGateway]: Constructor threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1070E:(pos 0): Problem parsing left operand
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:278)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1114)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1017)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
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:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.canaldigital.tsi.bank.config.AppMain.main(AppMain.java:32)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.integration.sftp.gateway.SftpOutboundGateway]: Constructor threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1070E:(pos 0): Problem parsing left operand
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:164)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:125)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:270)
... 14 more
Caused by: org.springframework.expression.spel.SpelParseException: EL1070E:(pos 0): Problem parsing left operand
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.raiseInternalException(InternalSpelExpressionParser.java:898)
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.checkLeftOperand(InternalSpelExpressionParser.java:916)
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.checkOperands(InternalSpelExpressionParser.java:910)
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatProductExpression(InternalSpelExpressionParser.java:234)
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatSumExpression(InternalSpelExpressionParser.java:213)
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatRelationalExpression(InternalSpelExpressionParser.java:168)
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatLogicalAndExpression(InternalSpelExpressionParser.java:156)
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatLogicalOrExpression(InternalSpelExpressionParser.java:144)
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatExpression(InternalSpelExpressionParser.java:104)
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.doParseExpression(InternalSpelExpressionParser.java:85)
at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:56)
at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:32)
at org.springframework.expression.common.TemplateAwareExpressionParser.parseExpression(TemplateAwareExpressionParser.java:76)
at org.springframework.expression.common.TemplateAwareExpressionParser.parseExpression(TemplateAwareExpressionParser.java:62)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.<init>(AbstractRemoteFileOutboundGateway.java:240)
at org.springframework.integration.sftp.gateway.SftpOutboundGateway.<init>(SftpOutboundGateway.java:45)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
... 16 more

ApplicationContext.xml

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-sftp="http://www.springframework.org/schema/integration/sftp"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.0.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/sftp
http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">


<context:component-scan base-package="com.canaldigital.tsi.bank" />
<context:property-placeholder location="classpath:settings.properties" />

<bean id="defaultSftpSessionFactory"
class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="${sftp.host}"/>
<property name="user" value="${sftp.username}"/>
<!-- <property name="password" value="${sftp.password}"/> -->
<property name="port" value="${sftp.serverPort}"/>

<!-- <property name="privateKey" value="${sftp.private.keyfile}"/> -->
<property name="privateKey" value="classpath:IBS_KEYS/id_rsa.txt"/>

<property name="privateKeyPassphrase" value="${sftp.passphrase}"/>

</bean>

<bean id="sftpSessionFactory" class="org.springframework.integration.file.remote.session.CachingSessionFactory">
<constructor-arg ref="defaultSftpSessionFactory" />
</bean>

<int-sftp:outbound-gateway id="gateway3"
session-factory="sftpSessionFactory"
request-channel="inbound1"
reply-channel="outbound"
auto-startup="true"
command="mv"
expression="/home/oracle/IBSTOBANK/Test/Outgoing/"
rename-expression="/home/oracle/IBSTOBANK/Test/Incoming/" />


<int:channel id="inbound1">
<int:queue/>
</int:channel>


<int:channel id="outbound"/>



</beans>

最佳答案

看来你应该研究什么是SpEL , 首先。

所以,你的问题在这里:

expression="/home/oracle/IBSTOBANK/Test/Outgoing/"
rename-expression="/home/oracle/IBSTOBANK/Test/Incoming/"

两者都不是正确的 SpEL 表达式。

从另一方面来说,如果您真的是指原始 路径表示,您应该在那里使用literal 技巧。只需将这些值用单引号引起来:

expression="'/home/oracle/IBSTOBANK/Test/Outgoing/'"
rename-expression="'/home/oracle/IBSTOBANK/Test/Incoming/'"

关于spring - SFTP 出站网关不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32050548/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com