gpt4 book ai didi

java - 使用 spring 集成复制文件

转载 作者:行者123 更新时间:2023-12-01 15:56:47 27 4
gpt4 key购买 nike

如何使用 spring 集成将文件从一个地方复制到另一个地方。就我而言,我想将 war 外部的文件复制到 war 内部。这是我正在考虑的代码片段:

<?xml version="1.0" encoding="UTF-8"?>

<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/integration"
xmlns:file="http://www.springframework.org/schema/integration/file"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd
http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail-1.0.xsd
">

<poller max-messages-per-poll="1" id="defaultPoller" default="true">
<interval-trigger interval="1000"/>
</poller>


<file:inbound-channel-adapter id="filesIn"
filename-pattern="ha-jdbc-cluster1.xml"
directory="file:/etc/****/" />


<file:outbound-channel-adapter id="filesOut" directory="classpath:/WEB-INF/classes" />

但遗憾的是它不起作用。有谁知道怎么做吗?

提前致谢......

最佳答案

我认为问题出在目标目录上。您使用的“classpath:”前缀不能用于写入文件,只能用于读取。

请告诉我们您想通过复制此路径的文件来实现什么目的,我们将尝试提出另一种方法来实现相同的目的。

关于java - 使用 spring 集成复制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4898749/

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