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. Spring点滴九:Spring bean的延迟初始化

    Spring bean延迟初始化: 官网API: By default, ApplicationContext implementations eagerly create and configure ...

  2. Fib的奇怪定理 : gcd(F[n],F[m])=F[gcd(n,m)]

    引理1:gcd(F[n],f[n-1])=1 因为 F[n]=f[n-1]+F[n-2] 所以 gcd(F[n],f[n-1]) = gcd(F[n-1]+F[n-2],F[n-1]) gcd的更损相 ...

  3. luogu2296 [NOIp2014]寻找道路 (bfs)

    反着建边,从T bfs找合法的点,然后再正着bfs一下求最短路就行了 #include<bits/stdc++.h> #define pa pair<int,int> #def ...

  4. Qt ------ WAV 音频文件介绍

    summary: wav 文件是有文件头的,播放时我们需要跳过文件头,否则开始播放有一小段时间的噪音,具体做法是:1.读取文件 2.读取位置指到文件头之后即可. 在资源交换文件RIFF标准中,所有的数 ...

  5. Dom选择器--内容文本操作

    一.文本内容操作 内容: <body> <div id="i1"> 学习是我快乐? <a>晚饭吃什么</a> </div> ...

  6. 最长回文子串问题-Manacher算法

    转:http://blog.csdn.net/dyx404514/article/details/42061017 Manacher算法 算法总结第三弹 manacher算法,前面讲了两个字符串相算法 ...

  7. Codeforces 923 A. Primal Sport

    http://codeforces.com/contest/923/problem/A 题意: 初始有一个x0,可以选择任意一个<x0的质数p,之后得到x1为≥x0最小的p的倍数 然后再通过x1 ...

  8. ubuntu中mysql中文乱码及用python3.x调用

    首先声明解决方法也是网上找来的,知识自己记下来以防以后用到.   ubuntu版本是14.04使用apt-get命令安装mysql sudo apt-get install mysql-server ...

  9. [转载]AngularJS 开发者最常犯的 10 个错误

    http://www.oschina.net/translate/top-10-mistakes-angularjs-developers-make

  10. HTML5页面开发的基础性模板

    分享一个HTML5页面开发的基础性模板,包含了两个版本: 开发版本 注释版本 开发版本 <!DOCTYPE html> <html> <head> <meta ...