首页 > 解决方案 > 无效的代码长度集和无效的 LOC 标头错误 - Maven

问题描述

我有一个 Maven 项目,它在运行 Maven 安装时返回以下堆栈跟踪:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.508 s
[INFO] Finished at: 2018-09-12T01:07:16-05:00
[INFO] Final Memory: 18M/64M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ExampleMvc: Compilation failure: Compilation failure:
[ERROR] error reading /Users/vismarkjuarez/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.32/tomcat-embed-core-8.5.32.jar; ZipFile invalid LOC header (bad signature)
[ERROR] error reading /Users/vismarkjuarez/.m2/repository/org/springframework/spring-web/5.0.8.RELEASE/spring-web-5.0.8.RELEASE.jar; ZipFile invalid LOC header (bad signature)
[ERROR] /Users/vismarkjuarez/eclipse-workspace/ExampleMvc/src/main/java/com/boot/training/ExampleMvc/App.java:[1,1] cannot access com.boot.training.ExampleMvc
[ERROR] invalid code lengths set
[ERROR] /Users/vismarkjuarez/eclipse-workspace/ExampleMvc/src/main/java/com/boot/training/ExampleMvc/ExampleController.java:[7,8] cannot access java.lang
[ERROR] invalid code lengths set
[ERROR] /Users/vismarkjuarez/eclipse-workspace/ExampleMvc/src/main/java/com/boot/training/ExampleMvc/ExampleController.java:[6,2] cannot find symbol
[ERROR] symbol: class RestController
[ERROR] /Users/vismarkjuarez/eclipse-workspace/ExampleMvc/src/main/java/com/boot/training/ExampleMvc/ExampleController.java:[10,16] cannot find symbol
[ERROR] symbol:   class String
[ERROR] location: class com.boot.training.ExampleMvc.ExampleController
[ERROR] -> [Help 1]

我已经尝试更新项目并强制更新快照和版本,但似乎没有任何效果。

下面是我的 pom.xml 文件:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.boot.training</groupId>
    <artifactId>ExampleMvc</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>ExampleMvc</name>
    <url>http://maven.apache.org</url>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.0.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.0.4.RELEASE</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

我究竟做错了什么?以上错误是什么意思?

标签: javamavenspring-boot

解决方案


尝试以下选项:

  1. 确保你有 java 8 集。例如在运行配置下的 eclipse 中检查 jre 指向的位置。如果不指向 java 8 ,则将其指向 java 8。

  2. 如果步骤 1 不起作用,请删除 your.m2/repository 文件夹并进行全新安装


推荐阅读