Intellij Idea Maven项目中Scala模块的Scala签名错误



免责声明:我是Scala的新手,并尝试使用Intellij Idea中的简单Scala ArchType创建一个示例Scala Maven项目。Intellij版本是14.1.2

下面是我的pom文件,我确实将Scala版本从2.7更改为2.11.6,默认情况下将生成。

<!-- language: lang-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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>learn.rxscala</groupId>
  <artifactId>rxscala-reactive-course-play</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <inceptionYear>2008</inceptionYear>
  <properties>
    <scala.version>2.11.6</scala.version>
    <slf4j.version>1.7.5</slf4j.version>
    <reactivex.version>0.23.0</reactivex.version>
    <rx.scala.compat.version>2.11</rx.scala.compat.version>
    <scala.async.version>0.9.2</scala.async.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.10</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.specs</groupId>
      <artifactId>specs</artifactId>
      <version>1.2.5</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.reactivex</groupId>
      <artifactId>rxscala_${rx.scala.compat.version}</artifactId>
      <version>${reactivex.version}</version>
    </dependency>
    <dependency>
      <groupId>org.scala-lang.modules</groupId>
      <artifactId>scala-async_${rx.scala.compat.version}</artifactId>
      <version>${scala.async.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.17</version>
    </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>
    </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>

在运行Maven测试时,我不断遵循错误 -

[WARNING] error: error while loading JUnit4, Scala signature JUnit4 has wrong version
[WARNING]  expected: 5.0
[WARNING]  found: 4.1 in JUnit4.class

我不确定如何解决此问题?

只需确保使用最新的scala-archetype-simple,因为Idea需要使用新的Scala-Archetype-simple即可。但是默认情况下,想法不能提供正确的Scala-SrcheType-simple选择,您需要自己输入正确的一个。

就像。

 groupId:net.alchim31.maven
 artifactId:scala-archetype-simple
 version:1.6
 packaging:maven-archetype

我也遇到了这个问题,在尝试手动纠正ver号码时,我发现使用终端或CMD简单,您可以构建一个新项目。

使用MVN命令确保您的项目是使用正确的VER构建的。

mvn -b原型:生成-darchetypegroupid = org.apache.maven.araven.archetypes -dgroupid = com.mycompany.app -dartifactid = my -app

参考:http://maven.apache.org/guides/getting-started/index.html

相关内容

  • 没有找到相关文章

最新更新