jdk10 出來后纤勒,本著玩玩新特性的原則着饥,在看了一部分說明文檔后(英文水平一般)参咙,看看社區(qū)的文章開始對SpirngBoot的旅行,
jdk10官方文檔硫眯,極力推薦去看看蕴侧,哪怕用翻譯軟件
筆者參考的博文
jdk10翻譯文檔
開發(fā)工具使用Idea2018.1 ,只有這個版本目前支持jdk10
- 導入依賴:ps本人使用的gradle
buildscript {
ext {
springBootVersion = '2.1.0.BUILD-SNAPSHOT'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.tanoak'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 10
repositories {
maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}
mavenLocal()
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.springframework.boot:spring-boot-devtools')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
- controller,沒有連接數(shù)據(jù)庫
@RestController
@RequestMapping(value = "test")
public class TestController {
@RequestMapping(value = "list")
public List toList(){
var list = List.of("張三","李四","王五") ;
return list ;
}
@RequestMapping(value = "map")
public Map<String,String> toMap(){
var map = Map.of("姓名","張三","性別","男") ;
return map ;
}
}
3.打開瀏覽器可以看到2.0_1.png
運行成功两入,可以看到SpringBoot2.1可以支持jdk10净宵,不過這不是LTS版,只能自己玩玩谆刨,var目前只能作局部變量,最后祝大家勞動節(jié)快樂归斤。愉快的加班