maven + scala + idea to build environment

Information form
Package version download link
maven 3.6.1 https://maven.apache.org/
jdk jdk1.8.0 https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Scala 2.11.7 https://www.scala-lang.org/download/all.html
IDEA The latest version of http://www.jetbrains.com/idea/

idea + java + scala installation configuration

idea + java + scala installation configuration reference another blog post: the Spark development environment to build (IDEA, Scala, SVN, SBT )


maven installation configuration

Enter the official website Home

Home .png official website


Download Source switch

Download Source .png switch


Select Download file

Choose to download the file .png


Extracting file (the following structure)

Unzip the file .png


Configure the environment variables (by default you will, will not you reference jdk configuration)

Configuration environment variable .png


Verify maven installation configuration

Verify maven installation configuration .png


Configuring the Central Warehouse (C: \ Tool \ maven3.6.1 \ conf \ settings.xml)

Add the following

<!--如果不了解mirrorOf的含义 建议在这里只配置一个阿里云,其他的仓库再pom.xml中配置-->
<mirrors>
    <!-- nexus-aliyun 首选,放第一位,有不能下载的包,再去做其他镜像的选择  -->
    <mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
</mirrors>

For example, most of my jar from Ali cloud,
but I use the spark is cdh or hdp's, found in Ali inside the cloud,
then I configure my warehouse-related information can be added in pom.xml file

<!--hdp仓库-->
    <repositories>
        <repository>
            <id>hortonworks</id>
            <url>https://repo.hortonworks.com/content/repositories/releases/</url>
        </repository>
    </repositories> 

Configuring local repository

Purpose: The default warehouse C:\Users\Administrator\.m2,
along with changes to the project, the jar may need more and more,
if the system disk exists consume a large amount of space, so you can migrate the warehouse to a non-system disk.

  1. The default system disk
    The default system disk .png

  2. Modify the configuration file ( C:\Tool\maven3.6.1\conf\settings.xml)
    to add the following
<!--因为我只有一个ssd,且只有一个盘,所以还放在C盘,各位自己随意-->
<localRepository>C:/Tool/maven3.6.1/repository</localRepository>
  1. Mobile configuration file
    will C:\Tool\maven3.6.1\conf\settings.xmlbe moved to C:\Users\Administrator\.m2the (two sides must ensure that the contents of the file as)
    delete C:\Users\Administrator\.m2under repositoryFolders
    Mobile profile .png

(This step can not do it, you can specify the path to the configuration file when the idea of ​​creating the project)


Configuring idea
  1. Create a new maven project
    image.png

image.png

image.png

image.png


  1. Configuration jdk
    Configuration jdk .png

  1. SDK configuration
    image.png
    (according to the actual selection)
    Select sdk.png

image.png


  1. Add scla structure
    create a file called scala folder in the main folder
    Establish scala folders .png

Right-click the scala folder,
selection Make Directory as,
and selection Sources Root,
(the scala root folder is marked as a source file, then all the codes in the Package therein, its path from the root directory to begin to run.)
Mark .png


  1. Established in scala scala file
    Establish scala .png file

Configuration pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>TestMaven</groupId>
    <artifactId>cn.lilcol</artifactId>
    <version>1.0-SNAPSHOT</version>

<!--aliyun外的仓库-->
    <repositories>
        <repository>
            <id>hortonworks</id>
            <url>https://repo.hortonworks.com/content/repositories/releases/</url>
        </repository>
    </repositories>

<!--具体依赖-->
    <dependencies>
        <!--spark-core_2.11:https://repo.hortonworks.com/content/repositories/releases/-->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.11</artifactId>
            <version>2.3.2.3.1.0.0-78</version>
        </dependency>
        
        <!--spark-streaming_2.11:https://repo.hortonworks.com/content/repositories/releases/-->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-streaming_2.11</artifactId>
            <version>2.3.2.3.1.0.0-78</version>
        </dependency>

        <!--spark-sql_2.11:https://repo.hortonworks.com/content/repositories/releases/-->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_2.11</artifactId>
            <version>2.3.2.3.1.0.0-78</version>
        </dependency>
    </dependencies>


</project>

Add rely wait to see the completion of a local warehouse
  1. External Libraries view the situation under (its dependencies have been added)
    External Libraries.png

  2. Check local repository (dependent has been stored in a local repository)
    Local warehouse .png


So far environment configuration
article for the original article, please indicate the source! ! !

Guess you like

Origin www.cnblogs.com/lillcol/p/11345814.html