【问题标题】:Spring cloud data flow unable to find fileSpring Cloud 数据流找不到文件
【发布时间】:2023-04-07 19:18:01
【问题描述】:

我在springboot中创建了一个微服务,resource文件夹下有一个文件夹,然后这个文件夹下有一个文件 即。

resource
      mycustomfolder
                  myfile.txt

我正在创建一个由myfile 填充的bean

@Value("${file-path}")
    private String filePath;

 @Bean
    public MyBean byBean() throws IOException {
//read file path
        String path = ResourceUtils.getURL(filePath).getPath();
//populated by bean
        MyBean myBean = myservice.populatedMyBean(path);
        return myBean;
    }

filePath 值在 application.property 中设置

dataload-config-file=src/main/resources/mycustomfolder/myfile.txt

当我执行这个 springboot 应用程序时,它是工作文件。

但是当我创建一个 jar 并使用 Spring Cloud 数据流进行部署时,它在创建 myBean 时出现错误 显示异常原因

Caused by: java.io.FileNotFoundException: /tmp/spring-cloud-dataflow-4865534318197521357/test-1506882530191/test.process/src/main/resources/mycustomfolder/myfile.txt (No such file or directory)

为什么这一切正常工作,但 spring-cloud-dataflow 抛出错误?

【问题讨论】:

    标签: spring spring-boot spring-cloud-stream spring-cloud-dataflow


    【解决方案1】:

    Spring Cloud Data Flow只能编排基于 Spring Cloud Stream (SCSt) 或 Spring Cloud Task (SCT) 的微服务应用程序。尚不清楚您的 Spring Boot 应用程序是否符合前面提到的框架。

    请使用SCStSCT 示例作为参考。如果您的应用程序确实符合 SCSt/SCT 编程模型,那么您最好共享源代码以供审核。

    【讨论】:

      猜你喜欢
      • 2020-11-22
      • 2016-10-13
      • 1970-01-01
      • 2019-03-02
      • 1970-01-01
      • 2019-07-23
      • 2019-10-17
      • 2018-06-14
      • 2018-10-24
      相关资源
      最近更新 更多