当我尝试使用最新的依赖项构建 Maven 空手道项目时出现编译错误

Posted

技术标签:

【中文标题】当我尝试使用最新的依赖项构建 Maven 空手道项目时出现编译错误【英文标题】:Compilation errors when i try to build Maven karate project with latest Dependencies 【发布时间】:2018-11-02 22:53:04 【问题描述】:
I m new to Karate API automation tool and just try to set up the tool.I'm getting Compilation errors when I try to compile (Clean install ) my maven project. 

感谢是否有人可以帮助我。这是在 0.6.0 上编译并正常工作的,我将其更改为最新版本。但现在它甚至对前一个都不起作用。

找到我正在使用的波纹管 PoM 文件: http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

    <groupId>com.test.karate</groupId>
    <artifactId>Examples</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
 <dependencies>
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-apache</artifactId>
            <version>0.8.0.RC3</version>
            <scope>test</scope>
        </dependency>            
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-junit4</artifactId>
            <version>0.8.0.RC3</version>
            <scope>test</scope>
        </dependency>       
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>$maven.compiler.version</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>$java.version</source>
                    <target>$java.version</target>
                    <compilerArgument>-Werror</compilerArgument>
                </configuration>

**Console log :** 
Building Examples 0.0.1-SNAPSHOT
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /Users/XXX/eclipse-workspace/Examples/src/main/java/Ru`enter code here`nnerKarate.java:[3,24] package org.junit.runner does not exist
[ERROR] /Users/XXX/eclipse-workspace/Examples/src/main/java/RunnerKarate.java:[5,1] package com.intuit.karate.junit4 does not exist
[ERROR] /Users/XXX/eclipse-workspace/Examples/src/main/java/RunnerKarate.java:[7,20] package cucumber.api does not exist
[ERROR] /Users/XXX/eclipse-workspace/Examples/src/main/java/RunnerKarate.java:[8,26] package cucumber.api.junit does not exist
[ERROR] /Users/uwickdi/eclipse-workspace/Examples/src/main/java/RunnerKarate.java:[10,2] cannot find symbol
  symbol: class RunWith
[ERROR] /Users/XXX/eclipse-workspace/Examples/src/main/java/RunnerKarate.java:[11,2] cannot find symbol
  symbol: class CucumberOptions
[INFO] 6 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ----------------------------------------------------------------

【问题讨论】:

【参考方案1】:

听起来您的本地 maven 存储库已损坏,因此请尝试清理并重新下载 JAR-s。你可以使用这个命令dependency:purge-local-repository

【讨论】:

以上是关于当我尝试使用最新的依赖项构建 Maven 空手道项目时出现编译错误的主要内容,如果未能解决你的问题,请参考以下文章

maven 缺少依赖项 jta-1.0.1b

获取最新的 Maven 依赖项。 [复制]

Maven - 使用依赖项构建 [重复]

无法解析配置':app:debugCompileClasspath的所有依赖项

Maven 依赖项:从 settings.xml 获取最新的忽略存储库

Maven - 在不构建的情况下安装项目依赖项