码迷,mamicode.com
首页 > 编程语言 > 详细

SpringBoot + Scala环境部署

时间:2019-04-30 19:50:50      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:.class   服务   package   pil   framework   创建   9.png   技术   mapping   

在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 技术图片?

特别注意:

技术图片?

参考博客: https://www.cnblogs.com/lilinzhiyu/p/7921890.html

SpringBoot + Scala环境部署

标签:.class   服务   package   pil   framework   创建   9.png   技术   mapping   

原文地址:https://www.cnblogs.com/suixingc/p/springboot--scala-huan-jing-bu-shu.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!