20. Developer Tools(开发者工具)
1 | Spring Boot includes an additional set of tools that can |
Spring Boot引入了额外的一些工具,让应用的开发体验变得更加愉快。spring-boot-devtools模块能够被任何项目引入提供“开发-时间”功能。如果需要支持devtools功能,增加如下模块到您的构建李,如下:
Maven:1
2
3
4
5
6
7<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
Gradle:1
2
3dependencies {
compile("org.springframework.boot:spring-boot-devtools")
}
1 | Developer tools are automatically disabled when running a |
当运行一个完整的应用jar包的时候,开发者工具集将会被自动禁用。如果您的应用是通过java -jar启动或者是通过一些特殊的类加载器启动的,它会被当做一个“产品级别的应用”。在Maven中标记devtools的依赖为可选的,在Gradle中使用compileOnly是防止devtools被传递依赖到您的其他模块的的最佳实践。1
2
3
4Repackaged archives do not contain devtools by default. If
you want to use a certain remote devtools feature, you need
to disable the excludeDevtoolsbuild property to include it.
The property is supported with both the Maven and Gradle plugins.
重新打包的档案在默认情况下不包含devtools。如果您想使用某个远程的devtools功能,您需要禁用excludeDevtoolsbuild属性去支持它。这个属性既支持Maven也支持Gradle。