创建Scalad的Maven项目遇到的问题

1.导入SDK的问题!
直接把bin的上一层目录给导入:Project Settings -> Libraries ->如图
在这里插入图片描述
重新启动即可

2.找不到Application

报错:Scala Cannot resolve symbol Application
Scala2.9以后就弃用了Application,所以使用2.11版本要用App替代Application,用Main替代App,需要将App文件修改成下面代码:

package com

/**
 * Hello world!
 *
 */
object Main extends App {
  println( "Hello World!" )
}

3.Scala signature JUnit4 has wrong version
Error:scalac: error while loading JUnit4, Scala signature JUnit4 has wrong version
expected: 5.0
found: 4.1 in JUnit4.class

解决办法:将maven自动生成的test下面的MySpec文件删除就好了
在这里插入图片描述
4.版本问题
改成2.11.12
在这里插入图片描述

我按照网上的教程搭建环境但是,一直报错,想请教下到底该如何解决,报错信息完全看不懂,谢谢各路大神 这个是写的代码 ![图片说明](https://img-ask.csdn.net/upload/201605/20/1463744165_364132.jpg) 这是报错信息 ![图片说明](https://img-ask.csdn.net/upload/201605/20/1463744176_437250.jpg) 这是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>scala70</groupId> <artifactId>scala70</artifactId> <version>1.0-SNAPSHOT</version> <inceptionYear>2008</inceptionYear> <properties> <scala.version>2.7.0</scala.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> ```
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页