【发布时间】: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