spark scala maven构建失败,错误为:无法访问value org.apache.spark.sql.types中的类型datatype

zxlwwiss  于 2021-07-12  发布在  Spark
关注(0)|答案(0)|浏览(253)

大家好,stackoverflowers,我有一个spark scala应用程序,它以前在scala 2.11和spark 2.4.4上运行。我正在尝试将scala版本更新到2.12,并将spark更新到3.0.0。当我将所有依赖项更改为scala 2.12兼容版本时,maven构建失败,出现以下错误:

  1. [ERROR] [Error] : missing or invalid dependency detected while loading class file 'Column.class'.
  2. Could not access type DataType in value org.apache.spark.sql.types,
  3. because it (or its dependencies) are missing. Check your build definition for
  4. missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic
  5. classpath.)
  6. A full rebuild may help if 'Column.class' was compiled against an incompatible version of
  7. org.apache.spark.sql.types.

还有导入语句 import org.apache.spark.sql.types.DataType 在ide中未解析。

这是我的完整pom.xml:

  1. <project xmlns="http://maven.apache.org/POM/4.0.0"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <groupId>cl.example.symphony</groupId>
  6. <artifactId>fwk-sym-data-crypto</artifactId>
  7. <version>0.0.1-SNAPSHOT</version>
  8. <packaging>jar</packaging>
  9. <properties>
  10. <maven.compiler.source>1.8</maven.compiler.source>
  11. <maven.compiler.target>1.8</maven.compiler.target>
  12. <encoding>UTF-8</encoding>
  13. <scala.version>2.12.0</scala.version>
  14. <scala-maven-plugin.version>4.0.0</scala-maven-plugin.version>
  15. </properties>
  16. <build>
  17. <plugins>
  18. <plugin>
  19. <groupId>org.apache.maven.plugins</groupId>
  20. <artifactId>maven-surefire-plugin</artifactId>
  21. <version>2.7</version>
  22. <configuration>
  23. <skipTests>true</skipTests>
  24. </configuration>
  25. </plugin>
  26. <plugin>
  27. <!-- see http://davidb.github.com/scala-maven-plugin -->
  28. <groupId>net.alchim31.maven</groupId>
  29. <artifactId>scala-maven-plugin</artifactId>
  30. <version>4.3.0</version>
  31. <executions>
  32. <execution>
  33. <goals>
  34. <goal>compile</goal>
  35. <goal>testCompile</goal>
  36. </goals>
  37. <configuration>
  38. <args>
  39. <!-- <arg>-make:transitive</arg> -->
  40. <arg>-dependencyfile</arg>
  41. <arg>${project.build.directory}/.scala_dependencies</arg>
  42. </args>
  43. </configuration>
  44. </execution>
  45. </executions>
  46. </plugin>
  47. <plugin>
  48. <artifactId>maven-assembly-plugin</artifactId>
  49. <version>2.4.1</version>
  50. <configuration>
  51. <descriptorRefs>
  52. <descriptorRef>jar-with-dependencies</descriptorRef>
  53. </descriptorRefs>
  54. </configuration>
  55. <executions>
  56. <execution>
  57. <id>make-assembly</id>
  58. <phase>package</phase>
  59. <goals>
  60. <goal>single</goal>
  61. </goals>
  62. </execution>
  63. </executions>
  64. </plugin>
  65. <plugin>
  66. <groupId>org.scalatest</groupId>
  67. <artifactId>scalatest-maven-plugin</artifactId>
  68. <version>1.0</version>
  69. <configuration>
  70. <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
  71. <junitxml>.</junitxml>
  72. <filereports>WDF TestSuite.txt</filereports>
  73. </configuration>
  74. <executions>
  75. <execution>
  76. <id>test</id>
  77. <goals>
  78. <goal>test</goal>
  79. </goals>
  80. </execution>
  81. </executions>
  82. </plugin>
  83. <plugin>
  84. <groupId>org.jacoco</groupId>
  85. <artifactId>jacoco-maven-plugin</artifactId>
  86. <version>0.8.5</version>
  87. <executions>
  88. <execution>
  89. <goals>
  90. <goal>prepare-agent</goal>
  91. </goals>
  92. </execution>
  93. <execution>
  94. <id>report</id>
  95. <phase>test</phase>
  96. <goals>
  97. <goal>report</goal>
  98. </goals>
  99. </execution>
  100. </executions>
  101. </plugin>
  102. <plugin>
  103. <artifactId>maven-shade-plugin</artifactId>
  104. <version>3.2.1</version>
  105. <executions>
  106. <execution>
  107. <phase>package</phase>
  108. <goals>
  109. <goal>shade</goal>
  110. </goals>
  111. <configuration>
  112. <transformers>
  113. <transformer
  114. implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/>
  115. </transformers>
  116. <filters>
  117. <filter>
  118. <artifact>*:*</artifact>
  119. <excludes>
  120. <exclude>META-INF/*.SF</exclude>
  121. <exclude>META-INF/*.DSA</exclude>
  122. <exclude>META-INF/*.RSA</exclude>
  123. </excludes>
  124. </filter>
  125. </filters>
  126. <shadedArtifactAttached>true</shadedArtifactAttached>
  127. </configuration>
  128. </execution>
  129. </executions>
  130. </plugin>
  131. </plugins>
  132. </build>
  133. <dependencies>
  134. <dependency>
  135. <groupId>org.scala-lang</groupId>
  136. <artifactId>scala-library</artifactId>
  137. <version>${scala.version}</version>
  138. </dependency>
  139. <dependency>
  140. <groupId>org.scala-lang</groupId>
  141. <artifactId>scalap</artifactId>
  142. <version>2.12.0</version>
  143. </dependency>
  144. <dependency>
  145. <groupId>com.typesafe.scala-logging</groupId>
  146. <artifactId>scala-logging_2.12</artifactId>
  147. <version>3.9.2</version>
  148. </dependency>
  149. <dependency>
  150. <groupId>org.apache.spark</groupId>
  151. <artifactId>spark-avro_2.12</artifactId>
  152. <version>3.0.0</version>
  153. </dependency>
  154. <dependency>
  155. <groupId>com.google.cloud.bigdataoss</groupId>
  156. <artifactId>gcs-connector</artifactId>
  157. <version>hadoop2-1.9.17</version>
  158. </dependency>
  159. <dependency>
  160. <groupId>org.apache.spark</groupId>
  161. <artifactId>spark-sql_2.12</artifactId>
  162. <version>3.0.0</version>
  163. </dependency>
  164. <dependency>
  165. <groupId>com.google.cloud.bigdataoss</groupId>
  166. <artifactId>bigquery-connector</artifactId>
  167. <version>hadoop2-0.13.9</version>
  168. </dependency>
  169. <dependency>
  170. <groupId>org.springframework.security</groupId>
  171. <artifactId>spring-security-core</artifactId>
  172. <version>5.2.1.RELEASE</version>
  173. </dependency>
  174. <dependency>
  175. <groupId>org.scala-lang.modules</groupId>
  176. <artifactId>scala-xml_2.12</artifactId>
  177. <version>1.3.0</version>
  178. </dependency>
  179. <dependency>
  180. <groupId>org.scalactic</groupId>
  181. <artifactId>scalactic_2.12</artifactId>
  182. <version>3.2.5</version>
  183. <scope>test</scope>
  184. </dependency>
  185. <dependency>
  186. <groupId>org.scalamock</groupId>
  187. <artifactId>scalamock-scalatest-support_2.12</artifactId>
  188. <version>3.6.0</version>
  189. <scope>test</scope>
  190. </dependency>
  191. <dependency>
  192. <groupId>org.scalatest</groupId>
  193. <artifactId>scalatest_2.12</artifactId>
  194. <version>3.2.2</version>
  195. <scope>test</scope>
  196. </dependency>
  197. <dependency>
  198. <groupId>org.apache.spark</groupId>
  199. <artifactId>spark-core_2.12</artifactId>
  200. <version>3.0.0</version>
  201. <type>test-jar</type>
  202. <scope>test</scope>
  203. </dependency>
  204. <!-- <dependency>-->
  205. <!-- <groupId>org.apache.spark</groupId>-->
  206. <!-- <artifactId>spark-sql_2.12</artifactId>-->
  207. <!-- <version>3.0.0</version>-->
  208. <!-- <type>test-jar</type>-->
  209. <!-- <scope>test</scope>-->
  210. <!-- </dependency>-->
  211. <dependency>
  212. <groupId>org.apache.logging.log4j</groupId>
  213. <artifactId>log4j-core</artifactId>
  214. <version>2.13.1</version>
  215. </dependency>
  216. <dependency>
  217. <groupId>org.apache.spark</groupId>
  218. <artifactId>spark-catalyst_2.12</artifactId>
  219. <version>3.0.0</version>
  220. <scope>test</scope>
  221. </dependency>
  222. <dependency>
  223. <groupId>org.apache.logging.log4j</groupId>
  224. <artifactId>log4j-api-scala_2.12</artifactId>
  225. <version>11.0</version>
  226. </dependency>
  227. <dependency>
  228. <groupId>com.typesafe</groupId>
  229. <artifactId>config</artifactId>
  230. <version>1.2.0</version>
  231. </dependency>
  232. <dependency>
  233. <groupId>org.scalacheck</groupId>
  234. <artifactId>scalacheck_2.12</artifactId>
  235. <version>1.15.3</version>
  236. <scope>test</scope>
  237. </dependency>
  238. <dependency>
  239. <groupId>org.apache.spark</groupId>
  240. <artifactId>spark-avro_2.12</artifactId>
  241. <version>3.0.0</version>
  242. <type>test-jar</type>
  243. <scope>test</scope>
  244. </dependency>
  245. <dependency>
  246. <groupId>net.liftweb</groupId>
  247. <artifactId>lift-json_2.12</artifactId>
  248. <version>3.4.3</version>
  249. </dependency>
  250. </dependencies>

有人能帮我找出错误吗?我查看了最新的sparkscala文档,似乎类数据类型仍然可用。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题