本文使用 Gradle 做爲構建工具,關於 Gradle 構建工具,能夠理解爲是 Maven 的升級版,我我的認爲比 Maven 好的地方是 Gradle 的 Groovy 的語法,比起 Maven 的 xml 語法,看起來要簡潔得多。git
allprojects { repositories { maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } } }
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.2.RELEASE'
compile("org.springframework.boot:spring-boot-devtools")
因此最後看起來是這樣:github
dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.2.RELEASE' compile("org.springframework.boot:spring-boot-devtools") }
buildscript { ext { springBootVersion = '1.5.2.RELEASE' } repositories { // NOTE: You should declare only repositories that you need here mavenLocal() mavenCentral() maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} maven { url "http://repo.spring.io/release" } maven { url "http://repo.spring.io/milestone" } maven { url "http://repo.spring.io/snapshot" } } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } }
這裏就一句話,這句話,我測試了好久才發現這句話必須加上去。web
apply plugin: 'spring-boot'
這時,咱們就能夠刷新 Gradle,看到全部的依賴都正常下載。spring
到這裏配置文件的配置就告一段落了,下面咱們還要配置 IntelliJ IDEA。intellij-idea
一、mac 電腦按下 command + alt + shift + / 出現:
app
二、找到 「compiler.automake.allow.when.app.running」 這個選項,而且勾選:
maven
此致,就大功告成了。ide
示例項目 GitHub 所在地址:https://github.com/weimingge14/SpringBootDevToolspring-boot