首页 > 解决方案 > 从 Jenkins 工作,得到 java.io.FileNotFoundException: 我能够在 eclipse 中运行同一个项目

问题描述

我在 Jenkins 的工作中遇到以下错误:

java.io.FileNotFoundException: testcases\Scenarios.xls 
  (The system cannot find the path specified)

尽管以下代码在 Eclipse 中执行时没有任何错误:

FileInputStream fis = new FileInputStream("Path/sample.xls");
Workbook wb = WorkbookFactory.create(fis);

标签: javajenkins

解决方案


如果您在 test/resources 中有 sample.xls,请使用以下代码。如果在 src 目录下的其他地方,请修改。FileInputStream fis = new FileInputStream(System.getProperty("user.dir") + "/src/test/resources/sample.xls");


推荐阅读