gpt4 book ai didi

java - guava-11.0.1.jar 和 eclipse 的 Maven 插件

转载 作者:行者123 更新时间:2023-11-29 05:49:15 25 4
gpt4 key购买 nike

我在 Eclipse 中创建了 maven 项目并添加了一些依赖项。

这里是一个完整的依赖列表:

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.caliper</groupId>
<artifactId>caliper</artifactId>
<version>0.5-rc1</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.1</version>
</dependency>
</dependencies>

然后我运行 Maven 安装并上传了所有 nesssery 库。

下次我收到以下消息时:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mywebapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ mywebapp ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\WORK_SPASE\mywebapp\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) @ mywebapp ---
[INFO] Compiling 1 source file to D:\WORK_SPACE\mywebapp\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.785s
[INFO] Finished at: Thu Jan 31 04:13:10 VET 2013
[INFO] Final Memory: 4M/121M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project mywebapp: Compilation failure
[ERROR] error: error reading C:\Users\User1\.m2\repository\com\google\guava\guava\11.0.1\guava-11.0.1.jar; invalid LOC header (bad signature)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

当我尝试运行我的类(class)时,我得到了:Exception in thread "main"java.lang.NoClassDefFoundError: com/google/common/base/Splitter

请给我一个建议。

最佳答案

首先我看到你有一个错误:

reading C:\Users\User1.m2\repository\com\google\guava\guava\11.0.1\guava-11.0.1.jar; invalid LOC header (bad signature)

可能是lib下载失败导致的。解决方案是删除文件夹 C:\Users\User1.m2\repository\com\google 并重试构建。

此外,我看到您使用的是非常旧的 maven-compiler-plugin (2.0.2) 版本,这让我得出结论,您没有配置 maven-compiler-plugin,这意味着您使用的是 java 1.4 但你至少需要 1.5。您必须像这样配置您的 maven-compiler-plugin:

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

也许你必须换到 1.5。

关于java - guava-11.0.1.jar 和 eclipse 的 Maven 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14621756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com