使用maven命令打开zip文件错误时出错

4 pom.xml maven

我执行了这个命令

mvn compile exec:java -Dexec.classpathScope=compile -Dexec.mainClass=trident.MyClass
Run Code Online (Sandbox Code Playgroud)

得到了这个

error: error reading ~/.m2/repository/com/google/guava/guava/13.0/guava-13.0.jar; 
error in opening zip file error: error reading ~/.m2/repository/com/fasterxml
/jackson/core/jackson-core/2.0.0/jackson-core-2.0.0.jar; error in opening zip file 
 error: 
error reading ~/.m2/repository/org/twitter4j/twitter4j-core/3.0.3/twitter4j-
core-3.0.3.jar; error in opening zip file
Run Code Online (Sandbox Code Playgroud)

我是maven的新手,这是Pom的一部分

<repository>
     <id>twitter4j.org</id> 
     <name>twitter4j.org Repository</name>
     <url>http://twitter4j.org/maven2</url>
     <releases>
        <enabled>true</enabled>  
     </releases>
     <snapshots>
        <enabled>true</enabled>
     </snapshots>
 </repository> 
Run Code Online (Sandbox Code Playgroud)

我很抱歉分离了POM文件的代码,因为我收到大部分代码的消息,应该添加细节

<dependencies>
   <dependency>
    <groupId>junit</groupId> 
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
</dependency>
<dependency> 
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.0.0</version>
</dependency>
<dependency>
    <groupId>org.twitter4j</groupId> 
    <artifactId>twitter4j-core</artifactId>
    <version>3.0.3</version>
 </dependency> 
 <dependency>
         <groupId>org.twitter4j</groupId> 
         <artifactId>twitter4j-stream</artifactId>
         <version>3.0.3</version> 
    </dependency> 
 </dependencies>
Run Code Online (Sandbox Code Playgroud)

和这部分POM文件

 <build>   
  <resources> 
   <resource> 
     <directory>${basedir}</directory>
     <includes>
       <include>twitter4j.properties</include>       
       <include>config.properties</include>
     </includes>
   </resource> 
 </resources>
Run Code Online (Sandbox Code Playgroud)

当我提取其中一个jar文件时,我得到了错误

End-of-central-directory signature not found. Either this file is not a zipfile, or it 
constitutes one disk of a multi-part archive. In the latter case the central directory 
and zipfile comment will be found on the last disk(s) of this archive. zipinfo: cannot 
find zipfile directory in one of ~/.m2/repository/com/google/guava/guava/13.0/guava-
13.0.jar ~/.m2/repository/com/google/guava/guava/13.0/guava-13.0.jar.zip, and cannot 
find ~/.m2/repository/com/google/guava/guava/13.0/guava-13.0.jar.ZIP, period
Run Code Online (Sandbox Code Playgroud)

出现错误的警告

[WARNING] POM for 'com.google.guava:guava:pom:13.0:provided' is invalid. Its 
dependencies (if any) will NOT be available to the current build. [WARNING] POM for 
'com.fasterxml.jackson.core:jackson-core:pom:2.0.0:compile' is invalid. Its 
dependencies (if any) will NOT be available to the current build. [WARNING] POM for 
'org.twitter4j:twitter4j-core:pom:3.0.3:compile' is invalid. Its dependencies (if any) 
will NOT be available to the current build. [WARNING] POM for 'org.twitter4j:twitter4j-
stream:pom:3.0.3:compile' is invalid.
Run Code Online (Sandbox Code Playgroud)

Mur*_*nik 5

似乎jar文件已损坏 - 您可以手动删除它(rm ~/.m2/repository/com/google/guava/guava/13.0/guava-13.0.jar),maven会在您运行时为您重新下载它mvn install.

  • 我试过了,但错误仍然存​​在.我发布了上面出现错误的警告 (2认同)