当前位置: 首页 > 知识库问答 >
问题:

Java解压缩后带有依赖项的zip文件找不到excel文件

凌声
2023-03-14

我必须压缩并上传我的测试自动化文件到Amazon WS设备场。当我试图查找excel文件时,Amazon日志给了我一个错误“没有这样的文件或目录”。

症状如下:

1)我可以在本地运行我的测试2)我可以从本地的excel文件中读取数据。3)我可以在amazon设备场上使用硬编码的数据运行我的测试。问题:4)我不能用zip文件中的excel文件中的数据运行我的测试用例

error java.io.filenotfoundException下面的test-classes文件夹amazon trows下的zip文件中的excel文件:file://tmp/scratchmiserm.scratch/test-package7ygtbu/referenceapp-appium-test-1.0-snapshot-tests.jar!/baggage.xlsx(没有这样的文件或目录

zip.xml

<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  <id>zip</id>
  <formats>
    <format>zip</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>${project.build.directory}</directory>
      <outputDirectory>./</outputDirectory>
      <includes>
        <include>*.jar</include>
        <include>*.xlsx</include>
        <include>*.properties</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>${project.build.directory}</directory>
      <outputDirectory>./</outputDirectory>
      <includes>
        <include>/dependency-jars/</include>
        <include>/test-classes/</include>
      </includes>
    </fileSet>
  </fileSets>
</assembly>

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.amazon.aws.adf.referenceapp.appium.test</groupId>
  <artifactId>Referenceapp-Appium-Test</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>ReferenceAppAppiumTests</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>com.thy.agentwebsales</groupId>
      <artifactId>bookingws-client</artifactId>
      <version>0.0.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>javax.xml.ws</groupId>
      <artifactId>jaxws-api</artifactId>
      <version>2.2.11</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>3.4.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.aventstack</groupId>
      <artifactId>extentreports</artifactId>
      <version>3.0.5</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>3.16</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi-ooxml</artifactId>
      <version>3.16</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>6.8.8</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.appium</groupId>
      <artifactId>java-client</artifactId>
      <version>5.0.0-BETA7</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>releases</id>
      <name>Archiva Managed Releases Repository</name>
      <url>http://repo.thy.com/artifactory/libs-releases-local</url>
    </repository>
    <repository>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <id>snapshots</id>
      <name>Archiva Managed Releases Repository</name>
      <url>http://repo.thy.com/artifactory/libs-snapshots-local</url>
    </repository>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <sourceDirectory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/src/main/java</sourceDirectory>
    <scriptSourceDirectory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/src/main/scripts</scriptSourceDirectory>
    <testSourceDirectory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/src/test/java</testSourceDirectory>
    <outputDirectory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/target/classes</outputDirectory>
    <testOutputDirectory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/target/test-classes</testOutputDirectory>
    <resources>
      <resource>
        <directory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/etc</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/etc</directory>
      </testResource>
    </testResources>
    <directory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/target</directory>
    <finalName>Referenceapp-Appium-Test-1.0-SNAPSHOT</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.8</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.3.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>default-jar</id>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.10</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/target/dependency-jars/</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.5.4</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <finalName>zip-with-dependencies</finalName>
              <appendAssemblyId>false</appendAssemblyId>
              <descriptors>
                <descriptor>src/main/assembly/zip.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.5</version>
        <executions>
          <execution>
            <id>default-clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>default-testResources</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testResources</goal>
            </goals>
          </execution>
          <execution>
            <id>default-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <executions>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
            </configuration>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.12.4</version>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <id>default-install</id>
            <phase>install</phase>
            <goals>
              <goal>install</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.7</version>
        <executions>
          <execution>
            <id>default-deploy</id>
            <phase>deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.3</version>
        <executions>
          <execution>
            <id>default-site</id>
            <phase>site</phase>
            <goals>
              <goal>site</goal>
            </goals>
            <configuration>
              <outputDirectory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/target/site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
          <execution>
            <id>default-deploy</id>
            <phase>site-deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
            <configuration>
              <outputDirectory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/target/site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <outputDirectory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/target/site</outputDirectory>
          <reportPlugins>
            <reportPlugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-project-info-reports-plugin</artifactId>
            </reportPlugin>
          </reportPlugins>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <outputDirectory>/Users/puren/Documents/workspace/JetMobile_iOS_AWS_Demo_TESTNG/target/site</outputDirectory>
  </reporting>
</project>

共有1个答案

鞠鸿雪
2023-03-14

为什么不直接将它与您的测试压缩到一个单独的资源目录中,然后像这样引用它:

./dependency-resources/someExcelfile.xlsx

您还可以使用我找到的这个java程序打印出工作目录,这样我们就有了一个参考点。

 类似资料:
  • 本文向大家介绍Java解压和压缩带密码的zip文件过程详解,包括了Java解压和压缩带密码的zip文件过程详解的使用技巧和注意事项,需要的朋友参考一下 前言 JDK自带的ZIP操作接口(java.util.zip包,请参看文章末尾的博客链接)并不支持密码,甚至也不支持中文文件名。 为了解决ZIP压缩文件的密码问题,在网上搜索良久,终于找到了winzipaes开源项目。 该项目在google cod

  • 本文向大家介绍Python压缩解压缩zip文件及破解zip文件密码的方法,包括了Python压缩解压缩zip文件及破解zip文件密码的方法的使用技巧和注意事项,需要的朋友参考一下 python 的 zipfile 提供了非常便捷的方法来压缩和解压 zip 文件。 例如,在py脚本所在目录中,有如下文件: 将 readability 目录中的文件压缩到脚本所在目录的 readability.zip

  • 问题内容: 我正在尝试解压缩一些zip文件,它的大小约为65兆。下面的代码段: 此方法实际上将文件解压缩: 那个执行者/未来的东西只是为了确保我正确地做。在类Finder中调用此方法,该类在目录中查找zip文件并尝试将其解压缩。它基于此代码http://docs.oracle.com/javase/tutorial/essential/io/walk.html 具体来说: 现在的问题。真的很有趣。

  • 我正在尝试解压文件使用Java,它正在编译没有任何错误。当我从工具中调用它,并给出文件的绝对目标路径和源路径时,例如:source:d:\data\test.zip destination:d:\data\op\ 我收到了类似访问被拒绝的错误(我有系统的管理访问权限) 堆栈跟踪: 正在提取:测试/新文本文档-复制(2).txt java.io.FileNotFoundException:d:\da

  • 问题内容: 我正在下载包含XML的压缩文件,由于延迟要求,我希望避免在操作之前将zip文件写入磁盘。但是,这不足以满足我的需求。没有办法说“这是一个zip文件的字节数组,请使用它”而不将其转换为流,并且它不可靠,因为它会扫描条目标头(请参阅EDIT下面的讨论,以了解为什么它不可靠)。 我尚无法访问要处理的zip文件,因此我不知道我是否能够通过来处理它们,因此我需要找到一种适用于任何有效ZIP文件的

  • 我有一个来自不同位置的文件列表。我使用以下代码创建了一个zip文件,该代码可以正常工作。但是,当我尝试在Windows中使用Extract All解压文件时,无法找到任何字节,但是如果我使用Windows资源管理器双击zip文件本身,我可以看到文件,并且可以打开单个文件并包含正确的数据