Spring Boot Gradle Tomcat 8 [英] Spring Boot Gradle Tomcat 8

查看:334
本文介绍了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.

这篇关于Spring Boot Gradle Tomcat 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆