1. 程式人生 > >spark與scala版本問題

spark與scala版本問題

異常資訊:

java.lang.NoSuchMethodError: scala.Product.$init$

事情的經過是這樣的:

1. 使用spark最新版本2.2.0測試SparkSql的DataFrame及Dataset的時候丟擲這個異常。

2. 開始懷疑是scala版本問題,於是沒多想安裝了scala最新版本2.1.2.4,然而依然報這個錯。

3. 鬱悶好久,甚至去研究cass class原理(因為cass class是自動實現scala.Product介面的,報錯資訊也在這裡),但是問題還是沒解決。

4. 但是直覺上感覺還是scala版本問題,最後抱著破罐子破摔再失敗一次也無妨的態度將scala的版本換為2.1.1.8,問題居然解決了!!!<此處是髒話>,沒想到scala版本過高也不行。

然後再次開啟官網,看到這樣的文字:

Spark runs on both Windows and UNIX-like systems (e.g. Linux, Mac OS). It’s easy to run locally on one machine — all you need is to have java installed on your system PATH, or the JAVA_HOME environment variable pointing to a Java installation.

Spark runs on Java 8+, Python 2.7+/3.4+ and R 3.1+. For the Scala API, Spark 2.2.0 uses Scala 2.11. You will need to use a compatible Scala version (2.11.x).

Note that support for Java 7, Python 2.6 and old Hadoop versions before 2.6.5 were removed as of Spark 2.2.0.

Note that support for Scala 2.10 is deprecated as of Spark 2.1.0, and may be removed in Spark 2.3.0.

教訓啊,如果一開始懷疑是版本問題就去官網看看多好。

希望能給同仁帶來幫助。