骆驼从类路径资源中读取文件? [英] Camel read file from classpath resource?

查看:20
本文介绍了骆驼从类路径资源中读取文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Spring Boot 应用程序的resources/file.txt"的类路径中有一个文件.

I have a file on the classpath at "resources/file.txt" in a Spring Boot app.

如何在骆驼路线中引用它?

How do i reference this in a Camel route?

我试过了:

from("file:resource:classpath:?fileName=file.txt") 及其变体.似乎没有任何效果.

from("file:resource:classpath:?fileName=file.txt") and variations on it. Nothing seems to work.

请问这里有什么解决方法吗?

Any workaround here pls?

谢谢

推荐答案

您不能为此使用文件组件,因为它旨在通过 java.io.File API 读取 - 例如文件系统上的常规文件.还有许多选项用于文件特定任务,例如读取锁定、移动文件以避免在处理后再次读取它们、删除文件以及扫描到子文件夹等.通过文件交换数据时所需的所有类型的任务.

You cannot use the file component for this, as its intended for reading via java.io.File API - eg regular files on file systems. Also many of the options are for file specific tasks such as read locks, moving files around to avoid reading them again after processing, deleting the file(s), and scan into sub folders etc. All kind of tasks needed when exchanging data via files.

要读取 JAR 文件中的资源,然后是 Java API 或流组件.

To read resources within JAR files, then you Java API or the stream component.

这篇关于骆驼从类路径资源中读取文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆