Spring Boot 中使用 spring-boot-devtools (使用 Gradle 作为构建工具)

本文使用 Gradle 作为构建工具,关于 Gradle 构建工具,可以理解为是 Maven 的升级版,我个人认为比 Maven 好的地方是 Gradle 的 Groovy 的语法,比起 Maven 的 xml 语法,看起来要简洁得多。

首先,我们引入阿里巴巴的 Maven 仓库,加快构建下载的速度

allprojects {
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
}
}

引入基本依赖

引入 Spring Boot 最最基础的依赖:

compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.2.RELEASE'

引入 spring-boot-devtools 的依赖:

compile("org.springframework.boot:spring-boot-devtools")

所以最后看起来是这样:

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")
}

加入仓库(很重要,决定了 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}")
}
}

加入插件(很重要,决定了 spring-boot-devtools 能否正确下载)

这里就一句话,这句话,我测试了很久才发现这句话必须加上去。

apply plugin: 'spring-boot'

这时,我们就可以刷新 Gradle,看到所有的依赖都正常下载。

到这里配置文件的配置就告一段落了,下面我们还要配置 IntelliJ IDEA。

配置 IntelliJ IDEA

勾选 Build project automatically 选项前的单选按钮。

接下来的设置

1、mac 电脑按下 command + alt + shift + / 出现:

2、找到 “compiler.automake.allow.when.app.running” 这个选项,并且勾选:

此致,就大功告成了。

示例项目 GitHub 所在地址:https://github.com/weimingge14/SpringBootDevTool

参考资料:

1、Intellij IDEA 使用Spring-boot-devTools无效解决办法

Spring Boot 中使用 spring-boot-devtools (使用 Gradle 作为构建工具)的更多相关文章

  1. Spring Boot中使用 Spring Security 构建权限系统

    Spring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架.它提供了一组可以在Spring应用上下文中配置的Bean,为应用系统提供声明式的安全 ...

  2. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->Spring Framework中的spring web MVC模块

    spring framework中的spring web MVC模块 1.概述 spring web mvc是spring框架中的一个模块 spring web mvc实现了web的MVC架构模式,可 ...

  3. 通过spring.net中的spring.caching CacheResult实现memcached缓存

    通过spring.net中的spring.caching CacheResult实现memcached缓存1.SpringMemcachedCache.cs2.APP.config3.Program. ...

  4. Spring Boot 中应用Spring data mongdb

    摘要 本文主要简单介绍下如何在Spring Boot 项目中使用Spring data mongdb.没有深入探究,仅供入门参考. 文末有代码链接 准备 安装mongodb 需要连接mongodb,所 ...

  5. Spring Boot中使用Spring Security进行安全控制

    我们在编写Web应用时,经常需要对页面做一些安全控制,比如:对于没有访问权限的用户需要转到登录表单页面.要实现访问控制的方法多种多样,可以通过Aop.拦截器实现,也可以通过框架实现(如:Apache ...

  6. 【swagger】1.swagger提供开发者文档--简单集成到spring boot中【spring mvc】【spring boot】

    swagger提供开发者文档 ======================================================== 作用:想使用swagger的同学,一定是想用它来做前后台 ...

  7. Spring Boot中集成Spring Security 专题

    check to see if spring security is applied that the appropriate resources are permitted: @Configurat ...

  8. 如何在静态方法或非Spring Bean中注入Spring Bean

           在项目中有时需要根据需要在自己new一个对象,或者在某些util方法或属性中获取Spring Bean对象,从而完成某些工作,但是由于自己new的对象和util方法并不是受Spring所 ...

  9. 怎么在项目中使用前端包管理器bower和构建工具gulp

    下面以WeUI(微信官方网页开发样式库)介绍一下,怎么把WeUi引入到自己的项目中,我的开发环境Visual Studio 2012,当然了Visual Studio 2015对此已有了更好的支持(h ...

随机推荐

  1. 分享一个linux系统中采用嵌套for循环比较两个数组内容,并输出相同值的shell脚本

    #!/bin/bash array1=(1 3 5 6 7 9) array2=(3 4 9) echo array1=${array1[@]} echo array2=${array2[@]} fo ...

  2. RBAC----基于角色的访问权限控制

    RBAC是什么? 基于角色的权限访问控制(Role-Based Access Control) 作为传统访问控制(自主访问.强制访问)的有前景的代替 受到了广泛的关注. 在RBAC中,权限与角色相关联 ...

  3. Java 线程池 8 大拒绝策略,面试必问!

    前言 谈到java的线程池最熟悉的莫过于ExecutorService接口了,jdk1.5新增的java.util.concurrent包下的这个api,大大的简化了多线程代码的开发.而不论你用Fix ...

  4. HNUSTOJ-1675 Morse Code(DFS+字典序搜索)

    1675: Morse Code 时间限制: 2 Sec  内存限制: 128 MB提交: 73  解决: 33[提交][状态][讨论版] 题目描述 摩尔斯电码(英语:Morse Code)是一种时通 ...

  5. HDUSTOJ-1559 Vive la Difference!(简单题)

    1559: Vive la Difference! 时间限制: 3 Sec  内存限制: 128 MB提交: 18  解决: 14[提交][状态][讨论版] 题目描述 Take any four po ...

  6. hdu1465不easy系列之中的一个(错排)

    版权声明:本文为博主原创文章,未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/37512659 转载请注明出 ...

  7. flask之上下文管理

    简单来说,falsk上下文管理可以分为三个阶段: 1.请求进来时,将请求鞋底的相关数据放入上下文管理中进行管理 2.在视图函数中,要去上下文管理中取值 3.请求响应之后,要将上下文管理中的数据清除 详 ...

  8. 通过runtime对类别进行属性的扩展

    category使用  objc_setAssociatedObject/objc_getAssociatedObject 实现添加属性 属性 其实就是 get/set 方法. 我们可以使用 objc ...

  9. Beta冲刺-(1/3)

    这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass1/ 这个作业要求在哪里 https://edu.cnbl ...

  10. Insomni'hack teaser 2019 - Misc - echoechoechoecho

    参考链接 https://ctftime.org/task/7456 题目内容 Echo echo echo echo, good luck nc 35.246.181.187 1337 解题过程 主 ...