2017-03-01 46 views
2

在我的scala項目中,我有一個依賴,在我的maven項目中工作正常,但在我的sbt項目中拋出錯誤。依賴在maven中工作正常,但在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> 
其實

dependency不存在。

但我在這裏的問題是:爲什麼在maven這個問題不顯示? maven中發生了什麼,它不在SBT中?

+0

大概是因爲Maven是建設項目,不運行它。你能顯示你的pom.xml嗎? – Adonis

回答

0

添加到build.sbt:

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

爲gradle這個見Elastic documentation

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