在pom.xml文件中添加:
<dependencies>中
<!-- 添加Scala依赖 -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<build>中
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>compile-scala</id>
<phase>compile</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile-scala</id>
<phase>test-compile</phase>
<goals>
<goal>add-source</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<recompileMode>incremental</recompileMode>
<scalaVersion>${scala.version}</scalaVersion> //此处的配置,要是写的不对,不能在idea中创建scala文件
<args>
<arg>-deprecation</arg>
</args>
<jvmArgs>
<jvmArg>-Xms64m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
</jvmArgs>
</configuration>
</plugin>
在main中,建立scala包,改为Sources Root

ScalaHelloBoot.class
package com.imooc.imoocbootscala.crontroller
import org.springframework.web.bind.annotation.{RequestMapping, RequestMethod, RestController}
@RestController
class ScalaHelloBoot {
@RequestMapping(value = Array("/sayScalaHello"), method = Array(RequestMethod.GET))
def sayHelloBoot = {
"Hello Scala Boot..."
}
}
在Web UI界面,打开服务器端口进行测试

http://localhost:7777/scala-boot/sayScalaHello

特别注意: