本文使用 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