zoukankan      html  css  js  c++  java
  • Maven Java项目添加Scala语言支持

    为了在一个普通的使用Maven构建的Java项目中,增加对Scala语言的支持。使得其能够同时编译Java和Scala语言的文件。其实很简单的一件事情,只需要在pom.xml文件中的build部分中的plugins中,增加对scala-maven-plugin的支持,就好了。具体的说,就是添加如下的语句:

          <plugin>
            <!-- see http://davidb.github.com/scala-maven-plugin -->
            <groupId>net.alchim31.maven</groupId>
            <artifactId>scala-maven-plugin</artifactId>
            <version>3.2.2</version>
            <executions>
              <execution>
                <goals>
                  <goal>compile</goal>
                  <goal>testCompile</goal>
                </goals>
                <configuration>
                  <args>
                    <arg>-dependencyfile</arg>
                    <arg>${project.build.directory}/.scala_dependencies</arg>
                  </args>
                </configuration>
              </execution>
            </executions>
            <configuration>
              <scalaVersion>2.11.8</scalaVersion>
            </configuration>
          </plugin>
    

    备注:

    1. 如果你的Maven项目的pom.xml中,没有build和plugins部分,请自行添加。

    2. scalaVersion请改成你自己安装的版本。

    3. 创建src/main/scala目录,并将Scala语言的文件,放入这个目录。

    这样以后,只要执行mvn clean compile,就可以同时编译src/main/scala和src/main/java目录下的文件了。

    执行生成的class文件,跟执行由Java生成的class文件一样,都可以使用mvn exec:java -Dexec.mainClass=[YOUR_CLASS_NAME]

  • 相关阅读:
    C#读取EXCEL中数字无法读取的方法
    学习Wml
    sqlserver.exe进程占cpu100%
    windows phone mango 页面跳转事件顺序
    Windows 8 系列(一):win 8 简介
    windows phone 小应用与随机算法的感悟
    文件下载
    html 表格固定宽度
    excel 导入科学计数法
    word 排版
  • 原文地址:https://www.cnblogs.com/jizhao/p/5961451.html
Copyright © 2011-2022 走看看