当前位置 主页 > 服务器问题 > Linux/apache问题 >
Scala是一门多范式的编程语言,一种类似Java的编程语言,设计初衷是实现可伸缩的语言并集成面向对象编程。Scala把Erlang风格的基于actor的并发带进了JVM,开发者可以利用Scala的actor模型在JVM上设计具伸缩性的并发应用程序,它会自动获得多核心处理器带来的优势,而不必依照复杂的Java线程模型来编写程序,接下来就介绍一下如何在SpringBoot框架中使用Scala来进行简单的Web开发,对scala不了解的建议先去学习基础哦
一、导入依赖
<?xml version="1.0" encoding="UTF-8"?> <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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.gjing.project</groupId> <artifactId>scala-demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name>scala-demo</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!--加入Scala依赖库--> <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>2.13.1</version> </dependency> <dependency> <groupId>cn.gjing</groupId> <artifactId>tools-starter-swagger</artifactId> <version>1.3.0</version> </dependency> <dependency> <groupId>cn.gjing</groupId> <artifactId>tools-common</artifactId> <version>1.2.7</version> </dependency> </dependencies> <build> <plugins> <!--加入Scala的编译插件,否则无法进行编译--> <plugin> <groupId>org.scala-tools</groupId> <artifactId>maven-scala-plugin</artifactId> <version>2.15.2</version> <executions> <execution> <goals> <goal>compile</goal> <goal>testCompile</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>