将数据保存到cassandra数据库中时,即
行:
com.datastax.spark.connector.japi.CassandraJavaUtil.javaFunctions(metricsRDD)
.writerBuilder("a2imetrics", "performance_data_stage",
mapToRow(PerfMetricsTable.class)).saveToCassandra();
在这一行上,我遇到了例外情况
我的Pom.xml如下:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<scala.version>2.11.8</scala.version>
<scala.main.version>2.11</scala.main.version>
<spark.version>2.3.0</spark.version>
<scalatest.version>3.0.0</scalatest.version>
<connector.version>2.3.0</connector.version>
<cassandra.version>3.0</cassandra.version>
<org.apache.spark.spark-core.version>2.3.0</org.apache.spark.spark-core.version>
<junit.version>4.12</junit.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<!-- Please make sure that following dependencies have versions corresponding
to the ones in your cluster. Note that spark-cassandra-connector should be
provided with '--packages' flag to spark-submit command. -->
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
<!-- <scope>provided</scope> -->
</dependency>
<!--<dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-core_${scala.main.version}</artifactId>
<version>${spark.version}</version> <scope>provided</scope> </dependency> -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.6.5</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_${scala.main.version}</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>14.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-client -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.9</version>
</dependency>
<!-- <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-hive_${scala.main.version}</artifactId>
<version>${spark.version}</version> <scope>provided</scope> </dependency> -->
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector_${scala.main.version}</artifactId>
<version>${connector.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.17.Final</version>
</dependency>
<!-- Test Dependencies <dependency> <groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector-embedded_${scala.main.version}</artifactId>
<version>${connector.version}</version> <scope>test</scope> <exclusions>
<exclusion> <groupId>com.datastax.cassandra</groupId> <artifactId>cassandra-driver-core</artifactId>
</exclusion> </exclusions> </dependency> <dependency> <groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.main.version}</artifactId> <version>${scalatest.version}</version>
<scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId>
<version>${junit.version}</version> <scope>test</scope> </dependency> <dependency>
<groupId>org.apache.cassandra</groupId> <artifactId>cassandra-all</artifactId>
<version>${cassandra.version}</version> <scope>test</scope> <exclusions> -->
<!-- Excluded to allow for Cassandra to run embedded <exclusion> <groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId> </exclusion> </exclusions> </dependency>
Force Guava 18 on Test CP, Required for Cassandra -->
</dependencies>
<!-- <build> <plugins> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version> <executions> <execution> <phase>process-sources</phase>
<goals> <goal>compile</goal> <goal>testCompile</goal> </goals> <configuration>
<mainSourceDir>${project.build.sourceDirectory}/../scala</mainSourceDir>
</configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <version>2.4.3</version> <executions>
<execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration>
</configuration> </execution> </executions> </plugin> -->
<!-- Instructions from http://www.scalatest.org/user_guide/using_the_scalatest_maven_plugin -->
<!-- disable surefire -->
<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version> <configuration> <skipTests>true</skipTests> </configuration>
</plugin> -->
<!-- enable scalatest -->
<!--<plugin> <groupId>org.scalatest</groupId> <artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version> <configuration> <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml> <filereports>WDF TestSuite.txt</filereports> </configuration>
<executions> <execution> <id>test</id> <goals> <goal>test</goal> </goals>
</execution> </executions> </plugin> </plugins> </build> -->
<!-- <dependencies> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId>
<version>1.1.1</version> </dependency> <dependency> <groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector_2.11</artifactId> <version>2.3.0</version>
</dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-core_2.11</artifactId>
<version>2.2.1</version> </dependency> <dependency> <groupId>junit</groupId>
<artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope>
</dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-sql_2.11</artifactId>
<version>2.3.1</version> </dependency> <dependency> <groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.11</artifactId> <version>2.2.1</version> </dependency>
<dependency> <groupId>com.datastax.cassandra</groupId> <artifactId>cassandra-driver-core</artifactId>
<version>3.5.0</version> </dependency> <dependency> <groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId> <version>0.11.0</version> </dependency>
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version>
</dependency> </dependencies> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.apache.spark.spark-core.version>2.2.1</org.apache.spark.spark-core.version>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target>
</properties> </project> -->