Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Maven编译Scala_Scala_Maven_Colossus - Fatal编程技术网

使用Maven编译Scala

使用Maven编译Scala,scala,maven,colossus,Scala,Maven,Colossus,我想使用maven创建一个hello world应用程序 以下是我的pom.xml: <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"&

我想使用maven创建一个hello world应用程序

以下是我的pom.xml:

<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>ColossusPlay</groupId>
  <artifactId>ColossusPlay</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
      <dependency>
        <groupId>com.tumblr</groupId>
        <artifactId>colossus-metrics_2.10</artifactId>
        <version>0.8.1-RC1</version>
    </dependency>
  </dependencies>
</project>
当我跑的时候

mvn package
它在目标目录中生成一个jar文件。然后我希望能够使用

scala target/ColossusPlay-0.0.1-SNAPSHOT.jar
但是,我得到如下NullPointer异常:

java.lang.NullPointerException
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at scala.reflect.internal.util.ScalaClassLoader$$anonfun$tryClass$1.apply(ScalaClassLoader.scala:43)
    at scala.reflect.internal.util.ScalaClassLoader$$anonfun$tryClass$1.apply(ScalaClassLoader.scala:43)
    at scala.util.control.Exception$Catch$$anonfun$opt$1.apply(Exception.scala:119)
    at scala.util.control.Exception$Catch$$anonfun$opt$1.apply(Exception.scala:119)
    at scala.util.control.Exception$Catch.apply(Exception.scala:103)
    at scala.util.control.Exception$Catch.opt(Exception.scala:119)
    at scala.reflect.internal.util.ScalaClassLoader$class.tryClass(ScalaClassLoader.scala:42)
    at scala.reflect.internal.util.ScalaClassLoader$class.tryToInitializeClass(ScalaClassLoader.scala:39)
    at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.tryToInitializeClass(ScalaClassLoader.scala:101)
    at scala.reflect.internal.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:63)
    at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101)
    at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:22)
    at scala.tools.nsc.JarRunner$.run(MainGenericRunner.scala:13)
    at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:29)
    at scala.tools.nsc.JarRunner$.runJar(MainGenericRunner.scala:25)
    at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:69)
    at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87)
    at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98)
    at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
    at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
我错过了什么

更新:


问题似乎是maven构建没有看到源文件。我试图强迫它在将nonesence写入源文件时出现构建错误,但mvn包仍然显示构建成功。另外,当我检查jar文件时,里面没有任何类文件。如何让maven看到源文件。

您必须添加一个缩放编译器插件,如sbt编译器插件


com.google.code.sbt-compiler-maven-plugin
sbt编译器maven插件
1.0.0-beta9
默认sbt编译
编译
测试编译

在特定用例(概要文件、复杂部署、深层层次结构)中使用带有scala的maven甚至比纯sbt更好,但在开始时有点棘手

您必须添加缩放编译器插件,如sbt编译器插件


com.google.code.sbt-compiler-maven-plugin
sbt编译器maven插件
1.0.0-beta9
默认sbt编译
编译
测试编译
在特定用例(概要文件、复杂部署、深层层次结构)中使用带有scala的maven甚至比纯sbt更好,但在开始时有点棘手

java.lang.NullPointerException
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at scala.reflect.internal.util.ScalaClassLoader$$anonfun$tryClass$1.apply(ScalaClassLoader.scala:43)
    at scala.reflect.internal.util.ScalaClassLoader$$anonfun$tryClass$1.apply(ScalaClassLoader.scala:43)
    at scala.util.control.Exception$Catch$$anonfun$opt$1.apply(Exception.scala:119)
    at scala.util.control.Exception$Catch$$anonfun$opt$1.apply(Exception.scala:119)
    at scala.util.control.Exception$Catch.apply(Exception.scala:103)
    at scala.util.control.Exception$Catch.opt(Exception.scala:119)
    at scala.reflect.internal.util.ScalaClassLoader$class.tryClass(ScalaClassLoader.scala:42)
    at scala.reflect.internal.util.ScalaClassLoader$class.tryToInitializeClass(ScalaClassLoader.scala:39)
    at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.tryToInitializeClass(ScalaClassLoader.scala:101)
    at scala.reflect.internal.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:63)
    at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101)
    at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:22)
    at scala.tools.nsc.JarRunner$.run(MainGenericRunner.scala:13)
    at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:29)
    at scala.tools.nsc.JarRunner$.runJar(MainGenericRunner.scala:25)
    at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:69)
    at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87)
    at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98)
    at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
    at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
 <plugin>
            <groupId>com.google.code.sbt-compiler-maven-plugin</groupId>
            <artifactId>sbt-compiler-maven-plugin</artifactId>
            <version>1.0.0-beta9</version>
            <executions>
                <execution>
                    <id>default-sbt-compile</id>
                    <goals>
                        <goal>compile</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>