【发布时间】:2017-11-08 17:59:36
【问题描述】:
我使用 spring-boot 开发了一个应用程序,我需要读取一个包含电子邮件的 csv 文件。
这是一个 sn-p 我是怎么做的:
public Set<String> readFile() {
Set<String> setOfEmails = new HashSet<String>();
try {
ClassPathResource cl = new ClassPathResource("myFile.csv");
File file = cl.getFile();
Stream<String> stream = Files.lines(Paths.get(file.getPath()));
setOfEmails = stream.collect(Collectors.toSet());
} catch (IOException e) {
logger.error("file error " + e.getMessage());
}
return setOfEmails;
}
当我使用 eclipse 执行应用程序时它可以工作:run As --> spring-boot app
但是当我将 jar 放入容器 docker 时,方法 readFile() 返回一个空集。
我使用 gradle 构建应用程序
你有什么想法吗?
【问题讨论】:
标签: java docker gradle spring-boot