1. 新建项目



  2. 建好之后





    建一个叫scala的文件夹

    并把它标记为root文件夹

  3. 修改pom.xml文件

    复制粘贴如下内容:

    添加的插件的作用,如果不添加,在新建文件的时候右键只能新建java的文件,无法创建scala的class和object。添加插件之后就可以了。
<properties>
<scala.version>2.11.8</scala.version>
<spring.version>2.0.2.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
<build>
<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>
<recompileMode>incremental</recompileMode>
<scalaVersion>${scala.version}</scalaVersion>
<launchers>
<launcher>
<id>app</id>
<mainClass>com.light.sword.ylazy.LightSwordApplication</mainClass>
<args>
<arg>-deprecation</arg>
</args>
<jvmArgs>
<jvmArg>-Xms256m</jvmArg>
<jvmArg>-Xmx2048m</jvmArg>
</jvmArgs>
</launcher>
</launchers>
</configuration>
<dependencies>
<!-- spring热部署-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
  1. 在scala(文件夹)下新建一个包,按照下图的层级关系,建好各个文件。

  1. 各个文件的内容
package xxproj

import org.springframework.boot.autoconfigure.SpringBootApplication

@SpringBootApplication
class AppConfig { }
package xxproj

import org.springframework.boot.SpringApplication

object xxprojApplication extends App {
SpringApplication.run(classOf[AppConfig])
}
package xxproj.controller

import com.alibaba.fastjson.JSONObject
import org.springframework.web.bind.annotation.{RequestMapping, RestController} @RestController
class indexController { @RequestMapping(value = Array("/index"))
def index(): JSONObject = {
val json = new JSONObject
json.put("code", 0)
json.put("data", "success")
json
}
}
  1. 运行xxprojApplication

    如果没报错就可以正常访问了

  2. 浏览器输入localhost:8080/index

欢迎关注微信公众号“ IT客“ ,投稿邮箱 itkeyy@163.com

SpringBoot中使用纯scala进行开发 配置教程 非常简单的案例的更多相关文章

  1. SpringBoot中整合Redis、Ehcache使用配置切换 并且整合到Shiro中

    在SpringBoot中Shiro缓存使用Redis.Ehcache实现的两种方式实例 SpringBoot 中配置redis作为session 缓存器. 让shiro引用 本文是建立在你是使用这sh ...

  2. 《转载》IntelliJ 2016.2 IDEA 中进行 Java Web 项目开发配置

    本文转载自 https://segmentfault.com/a/1190000007088964 1. 新建一个 Web Application 项目 打开 IntelliJ,选择新建项目: 左边栏 ...

  3. SpringBoot中 application.yml /application.properties常用配置介绍

    # Tomcat server: tomcat: uri-encoding: UTF-8 max-threads: 1000 min-spare-threads: 30 port: 10444 ser ...

  4. springboot中 后端跨域的实现配置

    在springboot的启动文件中,添加此内容,可以允许跨域

  5. springboot中redis做缓存时的配置

    import com.google.common.collect.ImmutableMap;import org.slf4j.Logger;import org.slf4j.LoggerFactory ...

  6. 关于springboot中文件上传,properties配置

    spring.http.multipart.enabled=true #默认支持文件上传. spring.http.multipart.file-size-threshold=0 #支持文件写入磁盘. ...

  7. 如何在springboot中读取自己创建的.properties配置的值

    在实体类里面加上 @PropertySource("classpath:/robot_config.properties") robot_config.properties // ...

  8. Spring配置文件中未引入dubbo命名空间头部配置而引起的错误案例

    问题描述: Spring配置文件中未引入dubbo命名空间的头部配置而引起项目启动时报出如下错误信息: org.springframework.beans.factory.xml.XmlBeanDef ...

  9. SSM 整合配置以及一个简单登陆案例(个人记录)

    SSM 文件以及大部分参考博客 https://blog.csdn.net/qq598535550/article/details/51703190 简答的登陆注册案例下载链接在末尾补贴图了 我建立的 ...

随机推荐

  1. Github Desktop 克隆仓库一直出现“Authentication failed”

    如图所示: 解决方法: 使用ssh链接下载而不是https

  2. 解题:NOI 2012 骑行川藏

    题面 入手点是每段路程中能量$e$与时间$t$的关系,$t-e$这个函数的导数对于各个路段一样,否则我们可以从导数大的一段路抽出一部分能量分给导数小的,这样会更优 毕姥爷在考场上的做法:猜一猜,然后拿 ...

  3. 《剑指offer》— JavaScript(32)把数组排成最小的数

    把数组排成最小的数 题目描述 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个.例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为3213 ...

  4. Openstack 错误日志查看方法

    openstack错误日志查看方法 https://blog.csdn.net/ZanShichun/article/details/72672945

  5. c++桥接模式

    可以简记为pointer to implement:”指向实现的指针”. [DP]书上定义:将抽象部分与它的实现部分分离,使它们都可以独立地变化.考虑装操作系统,有多种配置的计算机,同样也有多款操作系 ...

  6. Python核心编程的四大神兽:迭代器、生成器、闭包以及装饰器

      生成器 生成器是生成一个值的特殊函数,它具有这样的特点:第一次执行该函数时,先从头按顺序执行,在碰到yield关键字时该函数会暂停执行该函数后续的代码,并且返回一个值:在下一次调用该函数执行时,程 ...

  7. No module named flask.ext.script 解决方法

    把 .ext. 换成 _ 就OK了 from flask.ext.script import Manager from flask_script import Manager

  8. CM记录-CDH大数据平台实施经验总结2016(转载)

    CDH大数据平台实施经验总结2016(转载) 2016年负责实施了一个生产环境的大数据平台,用的CDH平台+docker容器的方式,过了快半年了,现在把总结发出来. 1. 平台规划注意事项 1.1 业 ...

  9. SpringBoot Logback日志配置

    Logback的配置介绍: 1.Logger.appender及layout Logger作为日志的记录器,把它关联到应用的对应的context上后,主要用于存放日志对象,也可以定义日志类型.级别. ...

  10. Phalcon框架之———— 2.0升级到3.0 问题Model验证问题解决

    Github源码:https://github.com/phalcon/cphalcon/tree/master/phalcon/validation/validator Phalcon 2.0 Mo ...