如果依赖项的POM.xml在" Profile"内部具有传递依赖性。 pom.xml的一部分然后这些依赖关系不是由SBT解决的,而是由Maven解决的。 例如: 当项目中包含以下依赖项时......
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>0.98.0-hadoop2</version>
</dependency>
...然后SBT不解决以下依赖关系,但是由maven解决:
hadoop-annotations , hadoop-mapreduce-client-core , hadoop-auth , hadoop-common
有人可以帮助我理解为什么这种分辨率的差异以及如何使SBT包含这些瞬态依赖性。
以下是测试build.sbt使用:
name := "StreamMaker"
version := "1.0"
scalaVersion := "2.10.4"
resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"
libraryDependencies += "org.apache.hbase" % "hbase-client" % "0.98.0-hadoop2"
net.virtualvoid.sbt.graph.Plugin.graphSettings
以下是hbase-client的pom.xml中的条目:
<profile>
<id>hadoop-2.0</id>
<activation>
<property>
<name>!hadoop.profile</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<exclusions>
<exclusion>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>tomcat</groupId>
<artifactId>jasper-compiler</artifactId>
</exclusion>
<exclusion>
<groupId>tomcat</groupId>
<artifactId>jasper-runtime</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-auth</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
<exclusions>
<exclusion>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly2</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-annotations</artifactId>
</dependency>
</dependencies>
</profile>
SBT 0.13.5解决的依赖性:
+-org.apache.hbase:hbase-client:0.98.0-hadoop2
+-com.github.stephenc.findbugs:findbugs-annotations:1.3.9-1
+-com.google.guava:guava:12.0.1
| +-com.google.code.findbugs:jsr305:1.3.9
|
+-com.google.protobuf:protobuf-java:2.5.0
+-commons-codec:commons-codec:1.7
+-commons-io:commons-io:2.4
+-commons-lang:commons-lang:2.6
+-commons-logging:commons-logging:1.1.1
+-io.netty:netty:3.6.6.Final
+-junit:junit:4.11
| +-org.hamcrest:hamcrest-core:1.3
|
+-log4j:log4j:1.2.17
+-org.apache.hbase:hbase-protocol:0.98.0-hadoop2
| +-com.github.stephenc.findbugs:findbugs-annotations:1.3.9-1
| +-com.google.protobuf:protobuf-java:2.5.0
| +-junit:junit:4.11
| | +-org.hamcrest:hamcrest-core:1.3
| |
| +-log4j:log4j:1.2.17
|
+-org.apache.zookeeper:zookeeper:3.4.5
| +-log4j:log4j:1.2.15 (evicted by: 1.2.17)
| +-log4j:log4j:1.2.16 (evicted by: 1.2.17)
| +-log4j:log4j:1.2.17
| +-org.slf4j:slf4j-api:1.6.1
| +-org.slf4j:slf4j-log4j12:1.6.1
| +-log4j:log4j:1.2.15 (evicted by: 1.2.17)
| +-log4j:log4j:1.2.16 (evicted by: 1.2.17)
| +-log4j:log4j:1.2.17
| +-org.slf4j:slf4j-api:1.6.1
|
+-org.cloudera.htrace:htrace-core:2.04
| +-com.google.guava:guava:12.0.1
| | +-com.google.code.findbugs:jsr305:1.3.9
| |
| +-commons-logging:commons-logging:1.1.1
| +-org.mortbay.jetty:jetty-util:6.1.26
|
+-org.codehaus.jackson:jackson-mapper-asl:1.8.8
+-org.codehaus.jackson:jackson-core-asl:1.8.8
Maven 3.0.4解决的依赖关系:
- org.apache.hbase:hbase-client:jar:0.98.0-hadoop2:compile
+- org.apache.hbase:hbase-common:jar:0.98.0-hadoop2:compile
| \- commons-collections:commons-collections:jar:3.2.1:compile
+- org.apache.hbase:hbase-protocol:jar:0.98.0-hadoop2:compile
+- commons-codec:commons-codec:jar:1.7:compile
+- commons-io:commons-io:jar:2.4:compile
+- commons-lang:commons-lang:jar:2.6:compile
+- commons-logging:commons-logging:jar:1.1.1:compile
+- com.google.guava:guava:jar:12.0.1:compile
| \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
+- com.google.protobuf:protobuf-java:jar:2.5.0:compile
+- io.netty:netty:jar:3.6.6.Final:compile
+- org.apache.zookeeper:zookeeper:jar:3.4.5:compile
+- org.cloudera.htrace:htrace-core:jar:2.04:compile
| \- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
+- org.codehaus.jackson:jackson-mapper-asl:jar:1.8.8:compile
| \- org.codehaus.jackson:jackson-core-asl:jar:1.8.8:compile
+- org.apache.hadoop:hadoop-common:jar:2.2.0:compile
| +- commons-cli:commons-cli:jar:1.2:compile
| +- org.apache.commons:commons-math:jar:2.1:compile
| +- xmlenc:xmlenc:jar:0.52:compile
| +- commons-httpclient:commons-httpclient:jar:3.1:compile
| +- commons-net:commons-net:jar:3.1:compile
| +- org.mortbay.jetty:jetty:jar:6.1.26:compile
| +- com.sun.jersey:jersey-core:jar:1.9:compile
| +- com.sun.jersey:jersey-json:jar:1.9:compile
| | +- org.codehaus.jettison:jettison:jar:1.1:compile
| | | \- stax:stax-api:jar:1.0.1:compile
| | +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
| | | \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
| | | \- javax.activation:activation:jar:1.1:compile
| | +- org.codehaus.jackson:jackson-jaxrs:jar:1.8.3:compile
| | \- org.codehaus.jackson:jackson-xc:jar:1.8.3:compile
| +- commons-el:commons-el:jar:1.0:runtime
| +- net.java.dev.jets3t:jets3t:jar:0.6.1:compile
| +- commons-configuration:commons-configuration:jar:1.6:compile
| | +- commons-digester:commons-digester:jar:1.8:compile
| | | \- commons-beanutils:commons-beanutils:jar:1.7.0:compile
| | \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
| +- org.apache.avro:avro:jar:1.7.4:compile
| | +- com.thoughtworks.paranamer:paranamer:jar:2.3:compile
| | \- org.xerial.snappy:snappy-java:jar:1.0.4.1:compile
| +- com.jcraft:jsch:jar:0.1.42:compile
| \- org.apache.commons:commons-compress:jar:1.4.1:compile
| \- org.tukaani:xz:jar:1.0:compile
+- org.apache.hadoop:hadoop-auth:jar:2.2.0:compile
+- org.apache.hadoop:hadoop-mapreduce-client-core:jar:2.2.0:compile
| +- org.apache.hadoop:hadoop-yarn-common:jar:2.2.0:compile
| | +- org.apache.hadoop:hadoop-yarn-api:jar:2.2.0:compile
| | +- com.google.inject:guice:jar:3.0:compile
| | | +- javax.inject:javax.inject:jar:1:compile
| | | \- aopalliance:aopalliance:jar:1.0:compile
| | +- com.sun.jersey:jersey-server:jar:1.9:compile
| | | \- asm:asm:jar:3.1:compile
| | \- com.sun.jersey.contribs:jersey-guice:jar:1.9:compile
| \- com.google.inject.extensions:guice-servlet:jar:3.0:compile
+- org.apache.hadoop:hadoop-annotations:jar:2.2.0:compile
| \- jdk.tools:jdk.tools:jar:1.7:system
+- com.github.stephenc.findbugs:findbugs-annotations:jar:1.3.9-1:compile
\- junit:junit:jar:4.11:compile
\- org.hamcrest:hamcrest-core:jar:1.3:compile
答案 0 :(得分:1)
sbt无法处理maven个人资料。 您应该将依赖项(在给定的配置文件中提到)添加到您的sbt文件中。
name := "StreamMaker"
version := "1.0"
scalaVersion := "2.10.4"
resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"
libraryDependencies += "org.apache.hbase" % "hbase-client" % "0.98.0-hadoop2"
// Add the dependencies from the active profile.
libraryDependencies ++= Seq("org.apache.hadoop" % "hadoop-mapreduce-client-core" % "2.2.0",
"org.apache.hadoop" % "hadoop-mapreduce-client-jobclient" % "2.2.0",
"org.apache.hadoop" % "hadoop-hdfs" % "2.2.0",
"org.apache.hadoop" % "hadoop-auth" % "2.2.0",
"org.apache.hadoop" % "hadoop-common" % "2.2.0",
"org.apache.hadoop" % "hadoop-client" % "2.2.0",
"org.apache.hadoop" % "hadoop-annotations" % "2.2.0")
net.virtualvoid.sbt.graph.Plugin.graphSettings
引用乔希:
Maven确实允许这样做,但这种形式很糟糕。你怎么知道的 哪个配置文件处于活动状态?基于更改依赖项 在活动配置文件中非常邪恶的用户。我联系那个 该项目的作者并要求他们找到另一种方法。