[Big data from introductory to discard series tutorial] in Idea's Java project, configure and join Scala, write and run Scala's Hello World

Source: Internet
Author: User

[Big data from introductory to discard series tutorial] in Idea's Java project, configure and join Scala, write and run Scala's Hello World

Original link: http://www.cnblogs.com/blog5277/p/8615984.html

Original Author: Blog Park------

Click on the menu below to view Big data Getting started all tutorials

Big data from getting started to giving up

Url:

Http://www.cnblogs.com/blog5277/category/1179528.html

Split ***********************************

In fact, the Java project is perfectly capable of developing the spark project, not necessarily the Scala to develop.

But the day days wondering people wish, the new project used the SUPERMAP components, their components to Scala support a little better, it shows that in Scala, a function of the entry parameters only two

But in Java, there are 4.

And then I don't know exactly what these parameters mean,

That's no way, only for Scala (plus Spark is based on the development of Scala, technical multi-body, learn to learn)

It never occurred to me that when I was using idea to integrate Scala, I met so many pits (partly because I wasn't aware of Scala).

Below to get to the chase:

Split ***********************************

One. Download the Scala plugin for idea

1. Personal Recommendation Method:

In idea--> set-up and search scala--> in the warehouse look up and down, find Scala, take a look at the corresponding version number, remember this version number

Then in:

Http://plugins.jetbrains.com/plugin/1347-scala

Go here to download the corresponding version ( download the zip do not unzip ):

After a very very long download .... After the download is finished, return to idea and select Add Local plugin on the settings page:

Select the zip you just downloaded, add, apply, OK, and idea will prompt you to restart idea to take effect, you reboot, the plugin is finished.

2. Less recommended way ... In idea--> settings--Plug-in search scala--> in the warehouse to search here, in fact, can be directly installed ...

Obviously so convenient, why I do not recommend it ... Because at home, the download speed of this plugin is too slow ... Also very easy to fail (method one is also very slow, but after all, the browser/Thunderbolt, will not fail, failure will also be a breakpoint continued), and here, extremely easy to fail ...

Open $$ Walk pac/global Agent/V Fart N method I have tried, and can not speed up the download speed, let people despair ...

Two, start Scala's Hello World

1. On the project, right-click, add frame support, select the Scala that appears

2. (Whether this option is optional or recommended) include the Scala-related jar package and the compile component plugin in Maven

Here is a tutorial on the great god of Yang under the Bodhi tree

Https://www.cnblogs.com/yjmyzz/p/4694219.html

<Dependencies>        <!--Https://mvnrepository.com/artifact/org.apache.spark/spark-core -        <Dependency>            <groupId>Org.apache.spark</groupId>            <Artifactid>spark-core_2.11</Artifactid>            <version>2.3.0</version>        </Dependency>        <!--https://mvnrepository.com/artifact/org.scala-lang/scala-library -        <Dependency>            <groupId>Org.scala-lang</groupId>            <Artifactid>Scala-library</Artifactid>            <version>2.12.4</version>        </Dependency>        <!--Https://mvnrepository.com/artifact/org.scala-lang/scala-compiler -        <Dependency>            <groupId>Org.scala-lang</groupId>            <Artifactid>Scala-compiler</Artifactid>            <version>2.12.4</version>        </Dependency>        <!--Https://mvnrepository.com/artifact/org.scala-lang/scala-reflect -        <Dependency>            <groupId>Org.scala-lang</groupId>            <Artifactid>Scala-reflect</Artifactid>            <version>2.12.4</version>        </Dependency>    </Dependencies>    <Build>        <Plugins>            <plugin>                <groupId>Org.scala-tools</groupId>                <Artifactid>Maven-scala-plugin</Artifactid>                <version>2.15.2</version>                <executions>                    <Execution>                        <Goals>                            <goal>Compile</goal>                            <goal>Testcompile</goal>                        </Goals>                    </Execution>                </executions>            </plugin>        </Plugins>    </Build>

3. Under Project Main, and Java at the same level, the new folder is called Scala, you can create a new Scala project under this file.

4. Here are 2 ways to run the Scala project, which has haunted me for a long time ...

5. Call in Java mode

Create a new Scala file with the default way to build a class file, such as:

In the new Scala file, press COMMAND + j (Windows should be alt ...). Do not try ctrl), or you can manually hit the following

After you lose the following code:

This time you will find that you can not run ...:

Point it will appear on the console, but this will not do you any grammar.

So no way, create a new Java file to run the Scala file, don't forget, Scala is also the JVM language, plus Kotlin, these two languages are known to be "seamless" with the Java project, the Scala project can certainly be run in Java, such as:

It is convenient to make Scala a Java class to tune on. Of .... Bar ...

6. Run Scala files directly

But Scala actually has its own way of working, which you have to choose when creating files, not using the default class, using Object ... (or you can change the above class to object)

In this case, there are running options, note the difference, here is the object

All right, that's it for today.

[Big data from introductory to discard series tutorial] in Idea's Java project, configure and join Scala, write and run Scala's Hello World

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.