maven中配置scala依赖的具体过程

1.idea创建项目

2.在idea中配置maven
这里具体过程不过多介绍,具体安装步骤可以参考网上具体资料

3.在idea中搜索Scala插件,然后安装,安装后选择restart重启idea

maven-scala-plugin版本很老了 maven scala_scala

maven-scala-plugin版本很老了 maven scala_ide_02

4.在pom文件中配置依赖

<dependencies>

    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>2.11.12</version>
    </dependency>

    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-compiler</artifactId>
        <version>2.11.12</version>
    </dependency>

    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-reflect</artifactId>
        <version>2.11.12</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <!-- Java Compiler -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <!-- Scala Compiler -->
        <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>

5.然后创建一个scala包,并添加为source root

maven-scala-plugin版本很老了 maven scala_ide_03

maven-scala-plugin版本很老了 maven scala_scala_04

6.然后就可以创建Scala文件进行代码的编写

maven-scala-plugin版本很老了 maven scala_scala_05

maven-scala-plugin版本很老了 maven scala_scala_06