我执行了这个命令
mvn compile exec:java -Dexec.classpathScope=compile -Dexec.mainClass=trident.MyClass
并得到了这个
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
我是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>
我很抱歉分离了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>
和POM文件的这一部分
<build>
<resources>
<resource>
<directory>${basedir}</directory>
<includes>
<include>twitter4j.properties</include>
<include>config.properties</include>
</includes>
</resource>
</resources>
我在提取其中一个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
出现错误的警告
[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.
答案 0 :(得分:5)
似乎jar文件已损坏 - 您可以手动将其删除(rm ~/.m2/repository/com/google/guava/guava/13.0/guava-13.0.jar
),当您运行mvn install
时,maven会为您重新下载。
答案 1 :(得分:0)
在POM文件中添加存储库标记。并运行作为Maven构建
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>