简体   繁体   English

日食的guava-11.0.1.jar和Maven插件

[英]guava-11.0.1.jar and Maven plugin for eclipse

I created maven project in Eclipse and added a few dependencies. 我在Eclipse中创建了maven项目并添加了一些依赖项。

Here is a full list of dependencies: 以下是依赖项的完整列表:

<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>

Then I ran Maven install and all nesssery libs were uploaded. 然后我运行了Maven安装并上传了所有nesssery库。

Next time I got the following message: 下次我收到以下消息:

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

And when I tried to run my class I got : Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Splitter 当我尝试运行我的类时,我得到: Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Splitter

Please give me a piece of advice. 请给我一点建议。

First I see that you have an error: 首先我看到你有一个错误:

reading C:\\Users\\User1.m2\\repository\\com\\google\\guava\\guava\\11.0.1\\guava-11.0.1.jar; 阅读C:\\ Users \\ User1.m2 \\ repository \\ com \\ google \\ guava \\ guava \\ 11.0.1 \\ guava-11.0.1.jar; invalid LOC header (bad signature) LOC标头无效(签名错误)

which might be caused by a failure during the download of the lib. 这可能是由于下载lib时出现故障造成的。 The solution is to delete the folder C:\\Users\\User1.m2\\repository\\com\\google and retry the build. 解决方案是删除文件夹C:\\ Users \\ User1.m2 \\ repository \\ com \\ google并重试构建。

Furthermore I see that you are using an extremely old version of the maven-compiler-plugin (2.0.2) which brings me to the conclusion that you didn't configured your maven-compiler-plugin which means you are using java 1.4 but you need at least 1.5. 此外,我看到你使用的是一个非常旧版本的maven-compiler-plugin(2.0.2),它让我得出结论,你没有配置你的maven-compiler-plugin,这意味着你使用的是java 1.4但是你需要至少1.5。 You have to configure your maven-compiler-plugin like this: 你必须像这样配置你的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>

Maybe you have to change to 1.5. 也许你必须改为1.5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM