0
我想使用scala應用程序訪問amazon s3存儲桶。我在eclipse中設置了scala IDE。但是,當我嘗試在我的本地(運行 - > Scala應用程序)上運行>應用程序時,它會在控制檯上出現以下錯誤。錯誤:無法找到或加載主類org.test.spark1.test我嘗試運行一個簡單的wordcount應用程序,其中我正在訪問存儲在我的S3存儲桶中的文件,並將結果存儲在另一個文件中。請讓我明白這個問題會是什麼。試圖使用scala應用程序訪問s3存儲桶
注意:我正在使用eclipse maven項目。我的Scala應用程序代碼是:
package org.test.spark1
import com.amazonaws._
import com.amazonaws.auth._
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import com.amazonaws.services.s3._
import com.amazonaws.services.s3.model.GetObjectRequest
import java.io.File;
object test extends App {
def main(args: Array[String]) {
val myAccessKey = "here is my key"
val mySecretKey = "here is my secret key"
val bucket = "nlp.spark.apps"
val conf = new SparkConf().setAppName("sample")
val sc = new SparkContext(conf)
val yourAWSCredentials = new BasicAWSCredentials(myAccessKey, mySecretKey)
val amazonS3Client = new AmazonS3Client(yourAWSCredentials)
// This will create a bucket for storage
amazonS3Client.createBucket("nlp-spark-apps2")
val s3data = sc.textFile("here is my url of text file")
s3data.flatMap(line =>
line.split(" "))
.map(word =>
(word, 1))
.reduceByKey(_ * _)
.saveAsTextFile("/home/hadoop/cluster-code2.txt")
}}
不需要'測試擴展App'和'main'方法。選擇一個。 –
我刪除了從代碼擴展應用程序..但錯誤仍然存在 –