依赖关系在maven中工作正常但在sbt中没有

时间:2017-03-01 16:35:38

标签: maven sbt

在我的scala项目中,我有一个在我的sbt项目中工作正常的依赖项,但在我的build.sbt项目中抛出错误。

在这种特定情况下,"com.sksamuel.elastic4s" % "elastic4s-xpack-security_2.11" % "5.1.5"中的依赖关系是: pom.xml

在我的[...] <properties> <maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target> <encoding>UTF-8</encoding> <scala.version>2.11.8</scala.version> <scala.compat.version>2.11</scala.compat.version> <spark.version>2.1.0</spark.version> </properties> [...] <repositories> <repository> <id>scala-tools.org</id> <name>Scala-Tools Maven2 Repository</name> <url>http://scala-tools.org/repo-releases</url> </repository> <repository> <id>elasticsearch-releases</id> <url>https://artifacts.elastic.co/maven</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>scala-tools.org</id> <name>Scala-Tools Maven2 Repository</name> <url>http://scala-tools.org/repo-releases</url> </pluginRepository> </pluginRepositories> <build> <finalName>${project.artifactId}-${project.version}</finalName> <sourceDirectory>src/main/scala</sourceDirectory> <testSourceDirectory>src/test/scala</testSourceDirectory> <pluginManagement> <plugins> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>scala-maven-plugin</artifactId> <version>3.2.1</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> </configuration> </plugin> </plugins> </pluginManagement> </build> <dependencies> <dependency> <groupId>com.sksamuel.elastic4s</groupId> <artifactId>elastic4s-xpack-security_${scala.compat.version}</artifactId> <version>5.1.5</version> </dependency> [...] 中:

[trace] Stack trace suppressed: run 'last *:update' for the full output.
[trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: org.elasticsearch.client#x-pack-transport;5.1.1: not found
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: org.elasticsearch.client#x-pack-transport;5.1.1: not found
[error] Total time: 13 s, completed Mar 1, 2017 4:40:59 PM</pre><br/>See complete log in <a href="/Users/salvob/Library/Logs/IdeaIC2016.3/sbt.last.log">/Users/salvob/Library/Logs/IdeaIC2016.3/sbt.last.log</a>

,显示的错误是:

<div *ngFor="let item of items; let index=index">
    <form name="itemForm">
        {{item.name}}<input [(ngModel)]="item.name" name={{index}}>
    </form>
</div>

实际上dependency不存在。

但我的问题是:为什么maven这个问题没有出现? maven在SBT中没有发生什么?

1 个答案:

答案 0 :(得分:0)

添加到build.sbt:

resolvers in ThisBuild += "elastic" at "https://artifacts.elastic.co/maven"

请参阅Elastic documentation了解gradle:

// Add the Elasticsearch Maven Repository
  maven {
    url "https://artifacts.elastic.co/maven"
  }