Spring Boot Gradle Tomcat 8
Spring Boot参考指南提供了通过在Maven中设置自定义属性来升级到Tomcat 8的指示:
The Spring Boot reference guide provides instructions for upgrading to Tomcat 8 by setting a custom property in Maven:
<properties>
<tomcat.version>8.0.3</tomcat.version>
</properties>
在Gradle构建中做同样的方法是什么?
What is the equivalent way to do the same in a Gradle build?
我试过以下方法无济于事。它在应用程序启动时停留在版本7.0.52上。
I have tried the following to no avail. It stays on version 7.0.52 at app startup.
buildscript {
...
ext['tomcat.version'] = '8.0.3'
...
}
Gradle没有相应的父pom,所以你必须显式地调用依赖。因为它很常用,所以你可以通过编程的方式来完成它,比如:
Gradle has no equivalent of a "parent pom", so you have to call out the dependency explicitly. Because it's groovy you can probably do it programmatically, something like:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.apache.tomcat.embed') {
details.useVersion '8.0.3'
}
}
}
我们可以将一些对版本属性的支持添加到Spring Boot Gradle插件(随时在github中打开问题),但它可能必须是可选的。
We could add some support for version properties to the Spring Boot Gradle plugin (feel free to open an issue in github) but it would probably have to be optional.