如何解决pom.xml中的缺少工件问题

时间:2019-02-18 21:44:18

标签: eclipse maven

我正在用Java启动一个简单的AWS dynamoDB测试。当然有像这样的进口

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;

因此,要解决此问题,我将我的项目声明为Maven性质,并在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>DynamoDBOperations</groupId>
<artifactId>DynamoDBOperations</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.3</version>
    <configuration>
      <source>1.8</source>
      <target>1.8</target>
    </configuration>
  </plugin>
</plugins>
</build>
<dependencies>
<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>bom</artifactId>
    <version>2.0.0</version>
</dependency>
</dependencies>
</project>

我有一个本地Artifactory实例正在运行,并且.m2目录settings.xml我在不同的条目中看到端点http://localhost:8081/artifactory/lib-(release和快照)。

pom.xml出现错误

Missing artifact software.amazon.awssdk:bom:jar: 2.0.0

当我尝试执行RunAs-Maven安装时,出现以下错误。

Failed to execute goal on project DynamoDBOperations: Could not resolve 
dependencies for project DynamoDBOperations:DynamoDBOperations:jar:0.0.1- 
SNAPSHOT: Failure to find software.amazon.awssdk:bom:jar:2.0.0 in 
http://localhost:8081/artifactory/libs-release was cached in the local 
repository, resolution will not be reattempted until the update interval of 
central has elapsed or updates are forced -> [Help 1] 

我知道它试图告诉我一些信息,但我不明白。

.m2下有一个存储库文件夹,其文件夹结构类似于我期望的software / amazon / awssdk / bom / 2.0.0,而在其下为bom-2.0.0.jar.lastupdated

java程序甚至还没有启动

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.model.AttributeDefinition;
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest;
import com.amazonaws.services.dynamodbv2.model.CreateTableResult;
import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
import com.amazonaws.services.dynamodbv2.model.KeyType;
import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput;
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType;
public class DynamoDBOperations {


}

1 个答案:

答案 0 :(得分:1)

这是在告诉您,对于software.amazon.awssdk,不存在jar bom-2.0.0.jar。

看看documentation

您必须在bom中定义一个dependencyManagement。还可以看看this answer

定义依赖项并执行maven命令时,即使maven无法下载依赖项,它也会自动创建文件夹结构。