当前位置: 首页 > 知识库问答 >
问题:

Maven未能拉入依赖项,编译失败

汝跃
2023-03-14

我对Maven相当陌生,试图编译一个非常简单的项目。这是我的pom。xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<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.bharani.aws</groupId>
    <artifactId>com.bharani.aws.dynamo</artifactId>
    <version>1.0-SNAPSHOT</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.amazonaws</groupId>
                <artifactId>aws-java-sdk-bom</artifactId>
                <version>1.11.106</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.16.16</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

</project>

当我执行mvn compile时,我得到一堆找不到符号错误。显然,依赖项没有下载和使用。这是错误日志:

f45c89aa1b75:bharani-aws-dynamo janakiab$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building com.bharani.aws.dynamo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ com.bharani.aws.dynamo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ com.bharani.aws.dynamo ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 2 source files to /Users/janakiab/code/bharani-aws-dynamo/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[3,54] package com.amazonaws.services.dynamodbv2.datamodeling does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[4,54] package com.amazonaws.services.dynamodbv2.datamodeling does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[5,54] package com.amazonaws.services.dynamodbv2.datamodeling does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[6,54] package com.amazonaws.services.dynamodbv2.datamodeling does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[7,14] package lombok does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[8,14] package lombok does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[9,14] package lombok does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[10,14] package lombok does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[11,14] package lombok does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[16,2] cannot find symbol
  symbol: class Data
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[17,2] cannot find symbol
  symbol: class Builder
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[18,2] cannot find symbol
  symbol: class ToString
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[19,2] cannot find symbol
  symbol: class NoArgsConstructor
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[20,2] cannot find symbol
  symbol: class AllArgsConstructor
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[21,2] cannot find symbol
  symbol: class DynamoDBTable
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[3,26] package com.amazonaws.auth does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[4,26] package com.amazonaws.auth does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[5,29] package com.amazonaws.regions does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[6,41] package com.amazonaws.services.dynamodbv2 does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[7,41] package com.amazonaws.services.dynamodbv2 does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[8,54] package com.amazonaws.services.dynamodbv2.datamodeling does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[33,13] cannot find symbol
  symbol:   class AmazonDynamoDB
  location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[41,44] cannot find symbol
  symbol:   class AmazonDynamoDB
  location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[41,13] cannot find symbol
  symbol:   class DynamoDBMapper
  location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[24,6] cannot find symbol
  symbol:   class DynamoDBAutoGeneratedKey
  location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[25,6] cannot find symbol
  symbol:   class DynamoDBHashKey
  location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[28,6] cannot find symbol
  symbol:   class DynamoDBAttribute
  location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[31,6] cannot find symbol
  symbol:   class DynamoDBAttribute
  location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[34,6] cannot find symbol
  symbol:   class DynamoDBAttribute
  location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[37,6] cannot find symbol
  symbol:   class DynamoDBAttribute
  location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[40,6] cannot find symbol
  symbol:   class DynamoDBAttribute
  location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[22,15] cannot find symbol
  symbol:   class AmazonDynamoDB
  location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[23,15] cannot find symbol
  symbol:   class DynamoDBMapper
  location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[36,38] cannot find symbol
  symbol:   class AWSStaticCredentialsProvider
  location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[37,29] cannot find symbol
  symbol:   class BasicAWSCredentials
  location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[35,29] cannot find symbol
  symbol:   variable Regions
  location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[34,16] cannot find symbol
  symbol:   variable AmazonDynamoDBClientBuilder
  location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[42,20] cannot find symbol
  symbol:   class DynamoDBMapper
  location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[46,28] cannot find symbol
  symbol:   method builder()
  location: class com.bharani.aws.CustomerInfo
[INFO] 39 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.560 s
[INFO] Finished at: 2017-10-04T18:46:40-07:00
[INFO] Final Memory: 15M/302M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project com.bharani.aws.dynamo: Compilation failure: Compilation failure:
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[3,54] package com.amazonaws.services.dynamodbv2.datamodeling does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[4,54] package com.amazonaws.services.dynamodbv2.datamodeling does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[5,54] package com.amazonaws.services.dynamodbv2.datamodeling does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[6,54] package com.amazonaws.services.dynamodbv2.datamodeling does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[7,14] package lombok does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[8,14] package lombok does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[9,14] package lombok does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[10,14] package lombok does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[11,14] package lombok does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[16,2] cannot find symbol
[ERROR] symbol: class Data
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[17,2] cannot find symbol
[ERROR] symbol: class Builder
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[18,2] cannot find symbol
[ERROR] symbol: class ToString
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[19,2] cannot find symbol
[ERROR] symbol: class NoArgsConstructor
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[20,2] cannot find symbol
[ERROR] symbol: class AllArgsConstructor
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[21,2] cannot find symbol
[ERROR] symbol: class DynamoDBTable
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[3,26] package com.amazonaws.auth does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[4,26] package com.amazonaws.auth does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[5,29] package com.amazonaws.regions does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[6,41] package com.amazonaws.services.dynamodbv2 does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[7,41] package com.amazonaws.services.dynamodbv2 does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[8,54] package com.amazonaws.services.dynamodbv2.datamodeling does not exist
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[33,13] cannot find symbol
[ERROR] symbol:   class AmazonDynamoDB
[ERROR] location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[41,44] cannot find symbol
[ERROR] symbol:   class AmazonDynamoDB
[ERROR] location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[41,13] cannot find symbol
[ERROR] symbol:   class DynamoDBMapper
[ERROR] location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[24,6] cannot find symbol
[ERROR] symbol:   class DynamoDBAutoGeneratedKey
[ERROR] location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[25,6] cannot find symbol
[ERROR] symbol:   class DynamoDBHashKey
[ERROR] location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[28,6] cannot find symbol
[ERROR] symbol:   class DynamoDBAttribute
[ERROR] location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[31,6] cannot find symbol
[ERROR] symbol:   class DynamoDBAttribute
[ERROR] location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[34,6] cannot find symbol
[ERROR] symbol:   class DynamoDBAttribute
[ERROR] location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[37,6] cannot find symbol
[ERROR] symbol:   class DynamoDBAttribute
[ERROR] location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/CustomerInfo.java:[40,6] cannot find symbol
[ERROR] symbol:   class DynamoDBAttribute
[ERROR] location: class com.bharani.aws.CustomerInfo
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[22,15] cannot find symbol
[ERROR] symbol:   class AmazonDynamoDB
[ERROR] location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[23,15] cannot find symbol
[ERROR] symbol:   class DynamoDBMapper
[ERROR] location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[36,38] cannot find symbol
[ERROR] symbol:   class AWSStaticCredentialsProvider
[ERROR] location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[37,29] cannot find symbol
[ERROR] symbol:   class BasicAWSCredentials
[ERROR] location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[35,29] cannot find symbol
[ERROR] symbol:   variable Regions
[ERROR] location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[34,16] cannot find symbol
[ERROR] symbol:   variable AmazonDynamoDBClientBuilder
[ERROR] location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[42,20] cannot find symbol
[ERROR] symbol:   class DynamoDBMapper
[ERROR] location: class com.bharani.aws.Main
[ERROR] /Users/janakiab/code/bharani-aws-dynamo/src/main/java/com/bharani/aws/Main.java:[46,28] cannot find symbol
[ERROR] symbol:   method builder()
[ERROR] location: class com.bharani.aws.CustomerInfo
[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
f45c89aa1b75:bharani-aws-dynamo janakiab$

如果我遗漏了什么,有人能指出我吗?

谢谢。

共有1个答案

鲁洋
2023-03-14

您的依赖项在

有关更多详细信息,请参阅maven依存关系管理页面。

 类似资料:
  • 我正在使用mongodb和Spring Boot。最近,我的mongodb升级到了3.0版本。 我对Spring使用以下Gradle依赖项: 如果我查看maven存储库中的gradle:,我会看到以下内容(http://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-mongodb/1.2.6

  • 我目前正在使用Maven开发一个Java项目。在我的我收到了这个错误。 我添加了这种依赖性 到我的。但错误仍然是一样的。 我是否缺少为依赖项添加存储库?我也没有在我的。 有人能建议我在我的中添加的存储库代码吗?

  • 我需要对maven依赖插件进行更改,以满足我的组织中的独特要求。 我已经从http://maven.apache.org/plugins/maven-dependency-plugin/download.cgi 当我查看它的pom时,我看到它定义了一个父pom,如下所示: 这让我明白,这个项目不能独立构建,至少不能是我拥有的版本。 当试图运行mvn清洁安装无论如何我得到以下错误: 无法下载工件:无

  • 我目前正在使用Maven处理一个Java项目。在我的pom.xml中,我得到了这个错误。 到我的pom.xml。但错误还是一样的。 有人能帮帮我吗?

  • 当我为我的项目运行“mvn dependency:tree”时,它会显示以下内容: 正如您在标记行中看到的,xml API具有“编译”作用域,因此它被打包到。战争档案。为什么会这样? 更有趣的是,它只在使用Java5时发生,对于Java6,依赖项显示为“test”。 Maven版本:3.0.4

  • Java和Maven新手。 我试图配置我的应用程序,以便我可以通过cmd线生成一个jar,其中包含我所有的依赖项。 据我所知,我正在正确设置Pom以使用此插件:https://github.com/javafx-maven-plugin/javafx-maven-plugin 以下是我在Pom中的依赖项: 在我的