Spring Boot 中使用 spring-boot-devtools (使用 Gradle 作为构建工具)
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 作为构建工具)的更多相关文章
- Spring Boot中使用 Spring Security 构建权限系统
Spring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架.它提供了一组可以在Spring应用上下文中配置的Bean,为应用系统提供声明式的安全 ...
- 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架构模式,可 ...
- 通过spring.net中的spring.caching CacheResult实现memcached缓存
通过spring.net中的spring.caching CacheResult实现memcached缓存1.SpringMemcachedCache.cs2.APP.config3.Program. ...
- Spring Boot 中应用Spring data mongdb
摘要 本文主要简单介绍下如何在Spring Boot 项目中使用Spring data mongdb.没有深入探究,仅供入门参考. 文末有代码链接 准备 安装mongodb 需要连接mongodb,所 ...
- Spring Boot中使用Spring Security进行安全控制
我们在编写Web应用时,经常需要对页面做一些安全控制,比如:对于没有访问权限的用户需要转到登录表单页面.要实现访问控制的方法多种多样,可以通过Aop.拦截器实现,也可以通过框架实现(如:Apache ...
- 【swagger】1.swagger提供开发者文档--简单集成到spring boot中【spring mvc】【spring boot】
swagger提供开发者文档 ======================================================== 作用:想使用swagger的同学,一定是想用它来做前后台 ...
- Spring Boot中集成Spring Security 专题
check to see if spring security is applied that the appropriate resources are permitted: @Configurat ...
- 如何在静态方法或非Spring Bean中注入Spring Bean
在项目中有时需要根据需要在自己new一个对象,或者在某些util方法或属性中获取Spring Bean对象,从而完成某些工作,但是由于自己new的对象和util方法并不是受Spring所 ...
- 怎么在项目中使用前端包管理器bower和构建工具gulp
下面以WeUI(微信官方网页开发样式库)介绍一下,怎么把WeUi引入到自己的项目中,我的开发环境Visual Studio 2012,当然了Visual Studio 2015对此已有了更好的支持(h ...
随机推荐
- OSPF与ACL 综合应用
1.企业内网运行OSPF路由协议,区域规划如图所示:2.财务和研发所在的区域不受其他区域链路不稳定性影响:3.R1.R2.R3只允许被IT登录管理:4.YF和CW之间不能互通,但都可以与IT互通:5. ...
- Desert King(01分数规划问题)(最优斜率生成树)
Desert King Time Limit: 3000MS Memory Limit: 65536K Total Submissions:33847 Accepted: 9208 Descr ...
- 【问题解决方案】Linux中命令useradd与adduser的区别
参考链接: useradd与adduser的区别 useradd与adduser:创建新的用户 CentOs: useradd与adduser是没有区别的 都是在创建用户,在home下自动创建目录,没 ...
- WindowsForms使用Telerik Reporting
新建一个WindowsForms窗体项目 然后拖动ReportViewer这个控件到WindowsForms的窗体中 如上图所示,用来呈现报表的控件,这个控件可以打印报表,转换报表这类的功能 接下来我 ...
- 2019-8-31-MobaXterm-使用代理
title author date CreateTime categories MobaXterm 使用代理 lindexi 2019-08-31 16:55:58 +0800 2018-02-13 ...
- 如何利用scrapy新建爬虫项目
抓取豆瓣top250电影数据,并将数据保存为csv.json和存储到monogo数据库中,目标站点:https://movie.douban.com/top250 一.新建项目 打开cmd命令窗口,输 ...
- STM32程序加载与调试
1.STM32程序的ISP下载,只能使用串口1,其它串口不可以.
- Java并发(具体实例)——几个例子
一步步优化页面渲染功能 本节将模拟一个简单的页面渲染功能,它的作用是将HTML页面绘 ...
- 费用流+SPFA ||【模板】最小费用最大流
题面:[模板]最小费用最大流 代码: #include<cstdio> #include<cstring> #include<iostream> #include& ...
- php 获取真实ip
REMOTE_ADDR:是和服务器直接"握手"的IP. HTTP_CLIENT_IP:代理服务器添加的 HTTP 头,存放客户端真实IP. HTTP_X_FORWARDED_FOR ...