java - 从 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);
解决方案
如果您在 test/resources 中有 sample.xls,请使用以下代码。如果在 src 目录下的其他地方,请修改。FileInputStream fis = new FileInputStream(System.getProperty("user.dir") + "/src/test/resources/sample.xls");
推荐阅读
- reactjs - Firebase 托管重定向网站没有所有页面
- reactjs - Antd 滑块未显示
- c++ - 如何使用标准工具计算给定大小和内容检查的 const char* 哈希
- python - 如何为深度学习中的多类创建多维 NumPy 数组?
- elasticsearch - Elasticsearch 索引无法识别日期(Logstash 管道)
- hive - 我尝试的 Hive 插入是否有解决方法
- jenkins - 以编程方式查找 Job DSL 插件生成的作业
- android - 在没有隐式广播的情况下收听 Oreo+ android 设备中的来电/去电
- regex - 该语言的哪个正则表达式是“最干净”或最有效的?
- python - 将图像文件上传到数据库