环境:
ubuntu14.04
scala2.10.5
Spark-1.5.2
Spark和scala之sbt问题
更多代码请见:https://github.com/xubo245/SparkLearning
按照参考【1】顺利安装了sbt,并显示
hadoop@Master:~/cloud/scala-2.10.5$ sbt sbt-version
[info] Set current project to scala-2-10-5 (in build file:/home/hadoop/cloud/scala-2.10.5/)
[info] 0.13.9
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt$ sbt compile
[info] Set current project to testbysbt (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/)
[info] Compiling 1 Scala source to /home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/target/scala-2.10/classes...
[error] /home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/SparkPi.scala:23: object apache is not a member of package org
[error] import org.apache.spark._
[error] ^
[error] /home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/SparkPi.scala:28: not found: type SparkConf
[error] val conf = new SparkConf().setAppName("Spark Pi")
[error] ^
[error] /home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/SparkPi.scala:29: not found: type SparkContext
[error] val spark = new SparkContext(conf)
[error] ^
[error] three errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 3 s, completed Jan 28, 2016 10:01:45 PM
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt$ sbt package
[info] Set current project to testbysbt (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/)
[info] Compiling 1 Scala source to /home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/target/scala-2.10/classes...
[error] /home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/SparkPi.scala:23: object apache is not a member of package org
[error] import org.apache.spark._
[error] ^
[error] /home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/SparkPi.scala:28: not found: type SparkConf
[error] val conf = new SparkConf().setAppName("Spark Pi")
[error] ^
[error] /home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/SparkPi.scala:29: not found: type SparkContext
[error] val spark = new SparkContext(conf)
[error] ^
[error] three errors found
[error] (compile:compileIncremental) Compilation failed
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt$ sbt assembly
[info] Set current project to testbysbt (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/)
[error] Not a valid command: assembly
[error] Not a valid project ID: assembly
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: assembly
[error] assembly
[error] ^
看书上是项目需要配置应用名,版本信息等。尚未解决。
解决办法:
参考【2】【3】的可行,但是很慢,明天再说
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt$ sbt compile
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/)
[info] Updating {file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/}testbysbt...
[info] Resolving net.java#jvnet-parent;1 ...
中间因为实验室网络问题断了几次,不过最终还是成功了,今天下午弄成功了。
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt$ sbt compile
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/)
[info] Updating {file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/}testbysbt...
Waiting for lock on /home/hadoop/.ivy2/.sbt.ivy.lock to be available...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] downloading http://maven.oschina.net/content/groups/public/log4j/log4j/1.2.17/log4j-1.2.17.jar ...
[info] [SUCCESSFUL ] log4j#log4j;1.2.17!log4j.jar(bundle) (678ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/slf4j/slf4j-log4j12/1.7.10/slf4j-log4j12-1.7.10.jar ...
[info] [SUCCESSFUL ] org.slf4j#slf4j-log4j12;1.7.10!slf4j-log4j12.jar (389ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/ning/compress-lzf/1.0.3/compress-lzf-1.0.3.jar ...
[info] [SUCCESSFUL ] com.ning#compress-lzf;1.0.3!compress-lzf.jar(bundle) (419ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/xerial/snappy/snappy-java/1.1.1.7/snappy-java-1.1.1.7.jar ...
[info] [SUCCESSFUL ] org.xerial.snappy#snappy-java;1.1.1.7!snappy-java.jar(bundle) (653ms)
[info] downloading http://maven.oschina.net/content/groups/public/net/jpountz/lz4/lz4/1.3.0/lz4-1.3.0.jar ...
[info] [SUCCESSFUL ] net.jpountz.lz4#lz4;1.3.0!lz4.jar (352ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/roaringbitmap/RoaringBitmap/0.4.5/RoaringBitmap-0.4.5.jar ...
[info] [SUCCESSFUL ] org.roaringbitmap#RoaringBitmap;0.4.5!RoaringBitmap.jar(bundle) (528ms)
[info] downloading http://maven.oschina.net/content/groups/public/commons-net/commons-net/2.2/commons-net-2.2.jar ...
[info] [SUCCESSFUL ] commons-net#commons-net;2.2!commons-net.jar (1347ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/typesafe/akka/akka-remote_2.10/2.3.11/akka-remote_2.10-2.3.11.jar ...
[info] [SUCCESSFUL ] com.typesafe.akka#akka-remote_2.10;2.3.11!akka-remote_2.10.jar (3153ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/typesafe/akka/akka-slf4j_2.10/2.3.11/akka-slf4j_2.10-2.3.11.jar ...
[info] [SUCCESSFUL ] com.typesafe.akka#akka-slf4j_2.10;2.3.11!akka-slf4j_2.10.jar (687ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/json4s/json4s-jackson_2.10/3.2.10/json4s-jackson_2.10-3.2.10.jar ...
[info] [SUCCESSFUL ] org.json4s#json4s-jackson_2.10;3.2.10!json4s-jackson_2.10.jar (517ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/sun/jersey/jersey-server/1.9/jersey-server-1.9.jar ...
[info] [SUCCESSFUL ] com.sun.jersey#jersey-server;1.9!jersey-server.jar(bundle) (1335ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/sun/jersey/jersey-core/1.9/jersey-core-1.9.jar ...
[info] [SUCCESSFUL ] com.sun.jersey#jersey-core;1.9!jersey-core.jar(bundle) (806ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/mesos/mesos/0.21.1/mesos-0.21.1-shaded-protobuf.jar ...
[info] [SUCCESSFUL ] org.apache.mesos#mesos;0.21.1!mesos.jar (1571ms)
[info] downloading http://maven.oschina.net/content/groups/public/io/netty/netty-all/4.0.29.Final/netty-all-4.0.29.Final.jar ...
[info] [SUCCESSFUL ] io.netty#netty-all;4.0.29.Final!netty-all.jar (2343ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/clearspring/analytics/stream/2.7.0/stream-2.7.0.jar ...
[info] [SUCCESSFUL ] com.clearspring.analytics#stream;2.7.0!stream.jar (732ms)
[info] downloading http://maven.oschina.net/content/groups/public/io/dropwizard/metrics/metrics-core/3.1.2/metrics-core-3.1.2.jar ...
[info] [SUCCESSFUL ] io.dropwizard.metrics#metrics-core;3.1.2!metrics-core.jar(bundle) (653ms)
[info] downloading http://maven.oschina.net/content/groups/public/io/dropwizard/metrics/metrics-jvm/3.1.2/metrics-jvm-3.1.2.jar ...
[info] [SUCCESSFUL ] io.dropwizard.metrics#metrics-jvm;3.1.2!metrics-jvm.jar(bundle) (430ms)
[info] downloading http://maven.oschina.net/content/groups/public/io/dropwizard/metrics/metrics-json/3.1.2/metrics-json-3.1.2.jar ...
[info] [SUCCESSFUL ] io.dropwizard.metrics#metrics-json;3.1.2!metrics-json.jar(bundle) (384ms)
[info] downloading http://maven.oschina.net/content/groups/public/io/dropwizard/metrics/metrics-graphite/3.1.2/metrics-graphite-3.1.2.jar ...
[info] [SUCCESSFUL ] io.dropwizard.metrics#metrics-graphite;3.1.2!metrics-graphite.jar(bundle) (484ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/fasterxml/jackson/core/jackson-databind/2.4.4/jackson-databind-2.4.4.jar ...
[info] [SUCCESSFUL ] com.fasterxml.jackson.core#jackson-databind;2.4.4!jackson-databind.jar(bundle) (1417ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/fasterxml/jackson/module/jackson-module-scala_2.10/2.4.4/jackson-module-scala_2.10-2.4.4.jar ...
[info] [SUCCESSFUL ] com.fasterxml.jackson.module#jackson-module-scala_2.10;2.4.4!jackson-module-scala_2.10.jar(bundle) (1064ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar ...
[info] [SUCCESSFUL ] org.apache.ivy#ivy;2.4.0!ivy.jar (1261ms)
[info] downloading http://maven.oschina.net/content/groups/public/oro/oro/2.0.8/oro-2.0.8.jar ...
[info] [SUCCESSFUL ] oro#oro;2.0.8!oro.jar (279ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/tachyonproject/tachyon-client/0.7.1/tachyon-client-0.7.1.jar ...
[info] [SUCCESSFUL ] org.tachyonproject#tachyon-client;0.7.1!tachyon-client.jar (2767ms)
[info] downloading http://maven.oschina.net/content/groups/public/net/razorvine/pyrolite/4.4/pyrolite-4.4.jar ...
[info] [SUCCESSFUL ] net.razorvine#pyrolite;4.4!pyrolite.jar (436ms)
[info] downloading http://maven.oschina.net/content/groups/public/net/sf/py4j/py4j/0.8.2.1/py4j-0.8.2.1.jar ...
[info] [SUCCESSFUL ] net.sf.py4j#py4j;0.8.2.1!py4j.jar (422ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/spark-project/spark/unused/1.0.0/unused-1.0.0.jar ...
[info] [SUCCESSFUL ] org.spark-project.spark#unused;1.0.0!unused.jar (302ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/avro/avro-ipc/1.7.7/avro-ipc-1.7.7-tests.jar ...
[info] [SUCCESSFUL ] org.apache.avro#avro-ipc;1.7.7!avro-ipc.jar (678ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/avro/avro-ipc/1.7.7/avro-ipc-1.7.7.jar ...
[info] [SUCCESSFUL ] org.apache.avro#avro-ipc;1.7.7!avro-ipc.jar (578ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/codehaus/jackson/jackson-core-asl/1.9.13/jackson-core-asl-1.9.13.jar ...
[info] [SUCCESSFUL ] org.codehaus.jackson#jackson-core-asl;1.9.13!jackson-core-asl.jar (838ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/codehaus/jackson/jackson-mapper-asl/1.9.13/jackson-mapper-asl-1.9.13.jar ...
[info] [SUCCESSFUL ] org.codehaus.jackson#jackson-mapper-asl;1.9.13!jackson-mapper-asl.jar (963ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/avro/avro/1.7.7/avro-1.7.7.jar ...
[info] [SUCCESSFUL ] org.apache.avro#avro;1.7.7!avro.jar (642ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/commons/commons-compress/1.4.1/commons-compress-1.4.1.jar ...
[info] [SUCCESSFUL ] org.apache.commons#commons-compress;1.4.1!commons-compress.jar (433ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/tukaani/xz/1.0/xz-1.0.jar ...
[info] [SUCCESSFUL ] org.tukaani#xz;1.0!xz.jar (314ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/esotericsoftware/kryo/kryo/2.21/kryo-2.21.jar ...
[info] [SUCCESSFUL ] com.esotericsoftware.kryo#kryo;2.21!kryo.jar(bundle) (666ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/esotericsoftware/reflectasm/reflectasm/1.07/reflectasm-1.07-shaded.jar ...
[info] [SUCCESSFUL ] com.esotericsoftware.reflectasm#reflectasm;1.07!reflectasm.jar (579ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/esotericsoftware/minlog/minlog/1.2/minlog-1.2.jar ...
[info] [SUCCESSFUL ] com.esotericsoftware.minlog#minlog;1.2!minlog.jar (507ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/objenesis/objenesis/1.2/objenesis-1.2.jar ...
[info] [SUCCESSFUL ] org.objenesis#objenesis;1.2!objenesis.jar (404ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-common/2.2.0/hadoop-common-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-common;2.2.0!hadoop-common.jar (3573ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-hdfs/2.2.0/hadoop-hdfs-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-hdfs;2.2.0!hadoop-hdfs.jar (14966ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-mapreduce-client-app/2.2.0/hadoop-mapreduce-client-app-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-mapreduce-client-app;2.2.0!hadoop-mapreduce-client-app.jar (1756ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-yarn-api/2.2.0/hadoop-yarn-api-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-yarn-api;2.2.0!hadoop-yarn-api.jar (1441ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-mapreduce-client-core/2.2.0/hadoop-mapreduce-client-core-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-mapreduce-client-core;2.2.0!hadoop-mapreduce-client-core.jar (2053ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-mapreduce-client-jobclient/2.2.0/hadoop-mapreduce-client-jobclient-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-mapreduce-client-jobclient;2.2.0!hadoop-mapreduce-client-jobclient.jar (370ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-annotations/2.2.0/hadoop-annotations-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-annotations;2.2.0!hadoop-annotations.jar (452ms)
[info] downloading http://maven.oschina.net/content/groups/public/commons-cli/commons-cli/1.2/commons-cli-1.2.jar ...
[info] [SUCCESSFUL ] commons-cli#commons-cli;1.2!commons-cli.jar (597ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/commons/commons-math/2.1/commons-math-2.1.jar ...
[info] [SUCCESSFUL ] org.apache.commons#commons-math;2.1!commons-math.jar (1561ms)
[info] downloading http://maven.oschina.net/content/groups/public/xmlenc/xmlenc/0.52/xmlenc-0.52.jar ...
[info] [SUCCESSFUL ] xmlenc#xmlenc;0.52!xmlenc.jar (440ms)
[info] downloading http://maven.oschina.net/content/groups/public/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar ...
[info] [SUCCESSFUL ] commons-httpclient#commons-httpclient;3.1!commons-httpclient.jar (436ms)
[info] downloading http://maven.oschina.net/content/groups/public/commons-codec/commons-codec/1.4/commons-codec-1.4.jar ...
[info] [SUCCESSFUL ] commons-codec#commons-codec;1.4!commons-codec.jar (261ms)
[info] downloading http://maven.oschina.net/content/groups/public/commons-lang/commons-lang/2.5/commons-lang-2.5.jar ...
[info] [SUCCESSFUL ] commons-lang#commons-lang;2.5!commons-lang.jar (604ms)
[info] downloading http://maven.oschina.net/content/groups/public/commons-configuration/commons-configuration/1.6/commons-configuration-1.6.jar ...
[info] [SUCCESSFUL ] commons-configuration#commons-configuration;1.6!commons-configuration.jar (494ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar ...
[info] [SUCCESSFUL ] com.google.protobuf#protobuf-java;2.5.0!protobuf-java.jar(bundle) (1055ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-auth/2.2.0/hadoop-auth-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-auth;2.2.0!hadoop-auth.jar (387ms)
[info] downloading http://maven.oschina.net/content/groups/public/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar ...
[info] [SUCCESSFUL ] commons-collections#commons-collections;3.2.1!commons-collections.jar (718ms)
[info] downloading http://maven.oschina.net/content/groups/public/commons-digester/commons-digester/1.8/commons-digester-1.8.jar ...
[info] [SUCCESSFUL ] commons-digester#commons-digester;1.8!commons-digester.jar (353ms)
[info] downloading http://maven.oschina.net/content/groups/public/commons-beanutils/commons-beanutils-core/1.8.0/commons-beanutils-core-1.8.0.jar ...
[info] [SUCCESSFUL ] commons-beanutils#commons-beanutils-core;1.8.0!commons-beanutils-core.jar (588ms)
[info] downloading http://maven.oschina.net/content/groups/public/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar ...
[info] [SUCCESSFUL ] commons-beanutils#commons-beanutils;1.7.0!commons-beanutils.jar (1522ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/mortbay/jetty/jetty-util/6.1.26/jetty-util-6.1.26.jar ...
[info] [SUCCESSFUL ] org.mortbay.jetty#jetty-util;6.1.26!jetty-util.jar (6151ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-mapreduce-client-common/2.2.0/hadoop-mapreduce-client-common-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-mapreduce-client-common;2.2.0!hadoop-mapreduce-client-common.jar (868ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-mapreduce-client-shuffle/2.2.0/hadoop-mapreduce-client-shuffle-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-mapreduce-client-shuffle;2.2.0!hadoop-mapreduce-client-shuffle.jar (529ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-yarn-common/2.2.0/hadoop-yarn-common-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-yarn-common;2.2.0!hadoop-yarn-common.jar (1431ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-yarn-client/2.2.0/hadoop-yarn-client-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-yarn-client;2.2.0!hadoop-yarn-client.jar (347ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-yarn-server-common/2.2.0/hadoop-yarn-server-common-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-yarn-server-common;2.2.0!hadoop-yarn-server-common.jar (384ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/google/inject/guice/3.0/guice-3.0.jar ...
[info] [SUCCESSFUL ] com.google.inject#guice;3.0!guice.jar (940ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/sun/jersey/jersey-test-framework/jersey-test-framework-grizzly2/1.9/jersey-test-framework-grizzly2-1.9.jar ...
[info] [SUCCESSFUL ] com.sun.jersey.jersey-test-framework#jersey-test-framework-grizzly2;1.9!jersey-test-framework-grizzly2.jar (939ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/sun/jersey/jersey-json/1.9/jersey-json-1.9.jar ...
[info] [SUCCESSFUL ] com.sun.jersey#jersey-json;1.9!jersey-json.jar(bundle) (447ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/sun/jersey/contribs/jersey-guice/1.9/jersey-guice-1.9.jar ...
[info] [SUCCESSFUL ] com.sun.jersey.contribs#jersey-guice;1.9!jersey-guice.jar (417ms)
[info] downloading http://maven.oschina.net/content/groups/public/javax/inject/javax.inject/1/javax.inject-1.jar ...
[info] [SUCCESSFUL ] javax.inject#javax.inject;1!javax.inject.jar (300ms)
[info] downloading http://maven.oschina.net/content/groups/public/aopalliance/aopalliance/1.0/aopalliance-1.0.jar ...
[info] [SUCCESSFUL ] aopalliance#aopalliance;1.0!aopalliance.jar (236ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/sonatype/sisu/inject/cglib/2.2.1-v20090111/cglib-2.2.1-v20090111.jar ...
[info] [SUCCESSFUL ] org.sonatype.sisu.inject#cglib;2.2.1-v20090111!cglib.jar (614ms)
[info] downloading http://maven.oschina.net/content/groups/public/asm/asm/3.1/asm-3.1.jar ...
[info] [SUCCESSFUL ] asm#asm;3.1!asm.jar (319ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/codehaus/jettison/jettison/1.1/jettison-1.1.jar ...
[info] [SUCCESSFUL ] org.codehaus.jettison#jettison;1.1!jettison.jar(bundle) (323ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/sun/xml/bind/jaxb-impl/2.2.3-1/jaxb-impl-2.2.3-1.jar ...
[info] [SUCCESSFUL ] com.sun.xml.bind#jaxb-impl;2.2.3-1!jaxb-impl.jar (708ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/codehaus/jackson/jackson-jaxrs/1.8.3/jackson-jaxrs-1.8.3.jar ...
[info] [SUCCESSFUL ] org.codehaus.jackson#jackson-jaxrs;1.8.3!jackson-jaxrs.jar (381ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/codehaus/jackson/jackson-xc/1.8.3/jackson-xc-1.8.3.jar ...
[info] [SUCCESSFUL ] org.codehaus.jackson#jackson-xc;1.8.3!jackson-xc.jar (483ms)
[info] downloading http://maven.oschina.net/content/groups/public/stax/stax-api/1.0.1/stax-api-1.0.1.jar ...
[info] [SUCCESSFUL ] stax#stax-api;1.0.1!stax-api.jar (211ms)
[info] downloading http://maven.oschina.net/content/groups/public/javax/xml/bind/jaxb-api/2.2.2/jaxb-api-2.2.2.jar ...
[info] [SUCCESSFUL ] javax.xml.bind#jaxb-api;2.2.2!jaxb-api.jar (315ms)
[info] downloading http://maven.oschina.net/content/groups/public/javax/activation/activation/1.1/activation-1.1.jar ...
[info] [SUCCESSFUL ] javax.activation#activation;1.1!activation.jar (508ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/hadoop/hadoop-yarn-server-nodemanager/2.2.0/hadoop-yarn-server-nodemanager-2.2.0.jar ...
[info] [SUCCESSFUL ] org.apache.hadoop#hadoop-yarn-server-nodemanager;2.2.0!hadoop-yarn-server-nodemanager.jar (3155ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/curator/curator-framework/2.4.0/curator-framework-2.4.0.jar ...
[info] [SUCCESSFUL ] org.apache.curator#curator-framework;2.4.0!curator-framework.jar(bundle) (522ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/zookeeper/zookeeper/3.4.5/zookeeper-3.4.5.jar ...
[info] [SUCCESSFUL ] org.apache.zookeeper#zookeeper;3.4.5!zookeeper.jar (532ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/google/guava/guava/14.0.1/guava-14.0.1.jar ...
[info] [SUCCESSFUL ] com.google.guava#guava;14.0.1!guava.jar(bundle) (3008ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/apache/curator/curator-client/2.4.0/curator-client-2.4.0.jar ...
[info] [SUCCESSFUL ] org.apache.curator#curator-client;2.4.0!curator-client.jar(bundle) (364ms)
[info] downloading http://maven.oschina.net/content/groups/public/jline/jline/0.9.94/jline-0.9.94.jar ...
[info] [SUCCESSFUL ] jline#jline;0.9.94!jline.jar (273ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/typesafe/akka/akka-actor_2.10/2.3.11/akka-actor_2.10-2.3.11.jar ...
[info] [SUCCESSFUL ] com.typesafe.akka#akka-actor_2.10;2.3.11!akka-actor_2.10.jar (4031ms)
[info] downloading http://maven.oschina.net/content/groups/public/io/netty/netty/3.8.0.Final/netty-3.8.0.Final.jar ...
[info] [SUCCESSFUL ] io.netty#netty;3.8.0.Final!netty.jar(bundle) (1261ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/uncommons/maths/uncommons-maths/1.2.2a/uncommons-maths-1.2.2a.jar ...
[info] [SUCCESSFUL ] org.uncommons.maths#uncommons-maths;1.2.2a!uncommons-maths.jar (528ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/typesafe/config/1.2.1/config-1.2.1.jar ...
[info] [SUCCESSFUL ] com.typesafe#config;1.2.1!config.jar(bundle) (545ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/scala-lang/scalap/2.10.0/scalap-2.10.0.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scalap;2.10.0!scalap.jar (917ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/scala-lang/scala-compiler/2.10.0/scala-compiler-2.10.0.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-compiler;2.10.0!scala-compiler.jar (20873ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/fasterxml/jackson/core/jackson-core/2.4.4/jackson-core-2.4.4.jar ...
[info] [SUCCESSFUL ] com.fasterxml.jackson.core#jackson-core;2.4.4!jackson-core.jar(bundle) (683ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/scala-lang/scala-reflect/2.10.4/scala-reflect-2.10.4.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-reflect;2.10.4!scala-reflect.jar (4104ms)
[info] downloading http://maven.oschina.net/content/groups/public/com/fasterxml/jackson/core/jackson-annotations/2.4.4/jackson-annotations-2.4.4.jar ...
[info] [SUCCESSFUL ] com.fasterxml.jackson.core#jackson-annotations;2.4.4!jackson-annotations.jar(bundle) (1270ms)
[info] downloading http://maven.oschina.net/content/groups/public/commons-io/commons-io/2.4/commons-io-2.4.jar ...
[info] [SUCCESSFUL ] commons-io#commons-io;2.4!commons-io.jar (385ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/tachyonproject/tachyon-underfs-hdfs/0.7.1/tachyon-underfs-hdfs-0.7.1.jar ...
[info] [SUCCESSFUL ] org.tachyonproject#tachyon-underfs-hdfs;0.7.1!tachyon-underfs-hdfs.jar (400ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/tachyonproject/tachyon-underfs-local/0.7.1/tachyon-underfs-local-0.7.1.jar ...
[info] [SUCCESSFUL ] org.tachyonproject#tachyon-underfs-local;0.7.1!tachyon-underfs-local.jar (463ms)
[info] downloading http://maven.oschina.net/content/groups/public/org/jboss/netty/netty/3.2.2.Final/netty-3.2.2.Final.jar ...
[info] [SUCCESSFUL ] org.jboss.netty#netty;3.2.2.Final!netty.jar(bundle) (683ms)
[info] Done updating.
[info] Compiling 1 Scala source to /home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/target/scala-2.10/classes...
[success] Total time: 6450 s, completed Jan 29, 2016 1:25:10 PM
老是停在:
Resolving ,这只是其中一次编译就耗时6450s。。。。。。
但编译成功后之后的编译就很快了:
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt$ sbt compile
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/)
[success] Total time: 2 s, completed Jan 29, 2016 4:07:54 PM
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt$ sbt package
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/)
[info] Packaging /home/hadoop/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt/target/scala-2.10/helloworld-project_2.10-1.0.jar ...
[info] Done packaging.
[success] Total time: 2 s, completed Jan 29, 2016 4:11:42 PM
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt$ ls target/scala-2.10/classes/
SparkPi$$anonfun$1.class SparkPi$$anonfun$2.class SparkPi.class SparkPi$.class
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/SparkPi/testBySbt$ ls target/scala-2.10/
classes helloworld-project_2.10-1.0.jar
进阶:1.在安装并编译好之后,如何在另外一个project中使用sbt编译scala程序?
新建文件夹,将原来安装好的配置文件移到本目录下:
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ cp ../backupSuccess/SparkPi/testBySbt/build.* ./
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ cp -r ../backupSuccess/SparkPi/testBySbt/project/ ./
</pre>再进行编译打包运行即可:<p></p><p></p><pre code_snippet_id="1569069" snippet_file_name="blog_20160129_17_4837555" name="code" class="plain">hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ sbt compile
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/LocalScala1/)
[info] Updating {file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/LocalScala1/}localscala1...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 1 Scala source to /home/hadoop/cloud/testByXubo/sh_spark_xubo/LocalScala1/target/scala-2.10/classes...
[success] Total time: 12 s, completed Jan 29, 2016 4:43:05 PM
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ ls target/scala-2.10/
classes
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ sbt package
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/LocalScala1/)
[info] Packaging /home/hadoop/cloud/testByXubo/sh_spark_xubo/LocalScala1/target/scala-2.10/helloworld-project_2.10-1.0.jar ...
[info] Done packaging.
[success] Total time: 2 s, completed Jan 29, 2016 4:43:44 PM
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ ls target/scala-2.10/
classes helloworld-project_2.10-1.0.jar
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ sbt run
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/LocalScala1/)
[info] Running testPrint1
hello,scala
hello,eclipse
[success] Total time: 2 s, completed Jan 29, 2016 4:44:00 PM
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ ls
build.properties build.sbt lib project run.sh target testPrintHelloXubo.scala testPrint.scala
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ vi run.sh
sbt compile
sbt package
sbt run
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ chmod 777 run.sh
返回运行结果:
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ ./run.sh
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/LocalScala1/)
[info] Compiling 1 Scala source to /home/hadoop/cloud/testByXubo/sh_spark_xubo/LocalScala1/target/scala-2.10/classes...
[success] Total time: 4 s, completed Jan 29, 2016 4:51:11 PM
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/LocalScala1/)
[warn] Multiple main classes detected. Run 'show discoveredMainClasses' to see the list
[info] Packaging /home/hadoop/cloud/testByXubo/sh_spark_xubo/LocalScala1/target/scala-2.10/helloworld-project_2.10-1.0.jar ...
[info] Done packaging.
[success] Total time: 2 s, completed Jan 29, 2016 4:51:18 PM
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/testByXubo/sh_spark_xubo/LocalScala1/)
[warn] Multiple main classes detected. Run 'show discoveredMainClasses' to see the list
Multiple main classes detected, select one to run:
[1] testPrint1
[2] testPrintHelloXubo
Enter number: 2
[info] Running testPrintHelloXubo
hello,scala
hello,eclipse
[success] Total time: 12 s, completed Jan 29, 2016 4:51:35 PM
为了方便,加入到local,可以不受目录限制,另外改了下名称:
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ mv run.sh sbtRun.sh
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ ls
build.properties build.sbt lib project sbtRun.sh target testPrintHelloXubo.scala testPrint.scala
加入到local:
hadoop@Master:~/cloud/testByXubo/sh_spark_xubo/LocalScala1$ sudo cp sbtRun.sh /usr/local/bin/
[sudo] password for hadoop:
hadoop@Master:~$ sbt
sbt sbt.bat sbt-launch.jar sbt-launch-lib.bash sbtRun.sh
参考:
【1】 http://www.linuxdiyf.com/linux/14871.html
【2】 http://www.aboutyun.com/thread-8587-1-1.html
【3】spark大数据处理 高彦杰【书】 P129
【4】 http://blog.csdn.net/cjuexuan/article/details/50574750