运行Maven简单Scala项目

时间:2019-11-21 14:05:15

标签: scala intellij-idea

我已经从scala-arcetype-simple和intelij IDE创建了maven项目。 pom是:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myxxx.scala</groupId>
  <artifactId>scala-0</artifactId>
  <version>1.0-SNAPSHOT</version>
  <inceptionYear>2008</inceptionYear>
  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <encoding>UTF-8</encoding>
    <scala.version>2.13.1</scala.version>
    <scala.compat.version>2.13</scala.compat.version>
  </properties>

  <repositories>
    <repository>
      <id>scala-tools.org</id>
      <name>Scala-Tools Maven2 Repository</name>
      <url>http://scala-tools.org/repo-releases</url>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>scala-tools.org</id>
      <name>Scala-Tools Maven2 Repository</name>
      <url>http://scala-tools.org/repo-releases</url>
    </pluginRepository>
  </pluginRepositories>

  <dependencies>
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>${scala.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.4</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.specs</groupId>
      <artifactId>specs</artifactId>
      <version>1.2.5</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <sourceDirectory>src/main/scala</sourceDirectory>
    <testSourceDirectory>src/test/scala</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <scalaVersion>${scala.version}</scalaVersion>
          <args>
            <arg>-target:jvm-1.5</arg>
          </args>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <configuration>
          <downloadSources>true</downloadSources>
          <buildcommands>
            <buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
          </buildcommands>
          <additionalProjectnatures>
            <projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
          </additionalProjectnatures>
          <classpathContainers>
            <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
            <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
          </classpathContainers>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <configuration>
          <scalaVersion>${scala.version}</scalaVersion>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
</project>

我得到的错误是:

Error:scalac: Error: assertion failed: 
  No Scala(Long)Signature annotation in classfile with ScalaSignature attribute: class JUnit4
     while compiling: D:\programming\workspace-intelij\src\test\scala\com\myxxx\scala\MySpec.scala
        during phase: globalPhase=typer, enteringPhase=namer
     library version: version 2.13.1
    compiler version: version 2.13.1
  reconstructed args: -classpath D:\programming\workspace-intelij\target\test-classes;D:\programming\workspace-intelij\target\classes;C:\Users\wolnosc\.m2\repository\org\scala-lang\scala-library\2.13.1\scala-library-2.13.1.jar;C:\Users\wolnosc\.m2\repository\junit\junit\4.4\junit-4.4.jar;C:\Users\wolnosc\.m2\repository\org\specs\specs\1.2.5\specs-1.2.5.jar;C:\Users\wolnosc\.m2\repository\org\scalatest\scalatest\0.9.1\scalatest-0.9.1.jar;C:\Users\wolnosc\.m2\repository\org\scalacheck\scalacheck\1.2\scalacheck-1.2.jar;C:\Users\wolnosc\.m2\repository\org\jmock\jmock\2.4.0\jmock-2.4.0.jar;C:\Users\wolnosc\.m2\repository\org\hamcrest\hamcrest-core\1.1\hamcrest-core-1.1.jar;C:\Users\wolnosc\.m2\repository\org\hamcrest\hamcrest-library\1.1\hamcrest-library-1.1.jar
  last tree to typer: Ident(JUnit4)
       tree position: line 6 of D:\programming\workspace-intelij\src\test\scala\com\myxxx\scala\MySpec.scala
              symbol: <none>
   symbol definition: <none> (a NoSymbol)
      symbol package: <none>
       symbol owners: 
           call site: class MySpecTest in package scala in package scala
== Source file context for tree position ==
     3 import org.specs._
     4 import org.specs.runner.{ConsoleRunner, JUnit4}
     5 
     6 class MySpecTest extends JUnit4(MySpec)
     7 //class MySpecSuite extends ScalaTestSuite(MySpec)
     8 object MySpecRunner extends ConsoleRunner(MySpec)
     9 
java.lang.AssertionError: assertion failed: 
  No Scala(Long)Signature annotation in classfile with ScalaSignature attribute: class JUnit4
     while compiling: D:\programming\workspace-intelij\src\test\scala\com\myxxx\scala\MySpec.scala
        during phase: globalPhase=typer, enteringPhase=namer
     library version: version 2.13.1
    compiler version: version 2.13.1
  reconstructed args: -classpath D:\programming\workspace-intelij\target\test-classes;D:\programming\workspace-intelij\target\classes;C:\Users\wolnosc\.m2\repository\org\scala-lang\scala-library\2.13.1\scala-library-2.13.1.jar;C:\Users\wolnosc\.m2\repository\junit\junit\4.4\junit-4.4.jar;C:\Users\wolnosc\.m2\repository\org\specs\specs\1.2.5\specs-1.2.5.jar;C:\Users\wolnosc\.m2\repository\org\scalatest\scalatest\0.9.1\scalatest-0.9.1.jar;C:\Users\wolnosc\.m2\repository\org\scalacheck\scalacheck\1.2\scalacheck-1.2.jar;C:\Users\wolnosc\.m2\repository\org\jmock\jmock\2.4.0\jmock-2.4.0.jar;C:\Users\wolnosc\.m2\repository\org\hamcrest\hamcrest-core\1.1\hamcrest-core-1.1.jar;C:\Users\wolnosc\.m2\repository\org\hamcrest\hamcrest-library\1.1\hamcrest-library-1.1.jar
  last tree to typer: Ident(JUnit4)
       tree position: line 6 of D:\programming\workspace-intelij\src\test\scala\com\myxxx\scala\MySpec.scala
              symbol: <none>
   symbol definition: <none> (a NoSymbol)
      symbol package: <none>
       symbol owners: 
           call site: class MySpecTest in package scala in package scala
== Source file context for tree position ==
     3 import org.specs._
     4 import org.specs.runner.{ConsoleRunner, JUnit4}
     5 
     6 class MySpecTest extends JUnit4(MySpec)
     7 //class MySpecSuite extends ScalaTestSuite(MySpec)
     8 object MySpecRunner extends ConsoleRunner(MySpec)

如何运行简单的Hello World?

0 个答案:

没有答案