IntelliJ is a very handy tool for Scala development that makes it easy to see Scala's source code, and of course it's cool to use it to develop Java, which has been using Scala Ides and Eclipse, and now it's IntelliJ to fly, But some people don't know how to use IntelliJ to create a spark project, here are two options file->new Project->java->scala, where the Scala version is 2.11.8
.
2. Then click Next, until finish, create the project see the following figure, this time you can create Scala file, then you can add spark related jar package, download from the official website http://spark.apache.org/ downloads.html, I use the spark-2.2.1-bin-hadoop2.7 here, you can choose the appropriate version according to your own needs, download the compressed package after the decompression
3. Select File->project structure->libraries, click +, select Java, Select the previously downloaded spark2.2-hadoop2.7 uncompressed jars folder, and then all the jar packages under this folder will be introduced into the project, as shown below
4. Then click on + in libraries, select Scala SDK, and select the system version of Scala for the 2.11.8 version, add see figure below
5. Project structure is similar to the following format after the addition is completed
6. The project now has spark jar and Scala SDK, then create a Scala file for testing, code and run results see the following figure
7. The above content shows that IntelliJ created the Spark project successfully, summing up this approach requires the introduction of Scala SDK and spark jar package, there is another way to see the following figure, select File->new project->scala- >idea, select Next
8. Then specify the project name and location of the project, click Finish, create the project
9. The project is created as follows, in which case you can directly right-click new to create a Scala file without needing to add the Scala SDK in additional
10. The next operation and the same as above, add spark jar package can be added after the test
11. Successful output, indicating that IntelliJ create Spark project success, of course, the premise is IntelliJ installed Scala plug-ins, in File->settings->plugins, search Scala, According to the results of the search after the installation restart IntelliJ can be, the following picture is I have installed
12. These are the two ways to create a spark project