弹簧靴Gradle Tomcat 8

弹簧靴Gradle Tomcat 8,tomcat,gradle,spring-boot,Tomcat,Gradle,Spring Boot,《Spring引导参考指南》提供了通过在Maven中设置自定义属性升级到Tomcat 8的说明: <properties> <tomcat.version>8.0.3</tomcat.version> </properties> Gradle没有“父pom”的等价物,因此必须显式地调用依赖项。因为它是groovy,所以您可能可以通过编程实现,比如: configurations.all { resolutionStrategy.eachD

《Spring引导参考指南》提供了通过在Maven中设置自定义属性升级到Tomcat 8的说明:

<properties>
  <tomcat.version>8.0.3</tomcat.version>
</properties>

Gradle没有“父pom”的等价物,因此必须显式地调用依赖项。因为它是groovy,所以您可能可以通过编程实现,比如:

configurations.all {
  resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    if (details.requested.group == 'org.apache.tomcat.embed') {
        details.useVersion '8.0.3'
    }
  }
}  

我们可以为Spring Boot Gradle插件添加一些版本属性支持(可以在github中随意打开一个问题),但它可能必须是可选的。

请看一下Gretty插件:它支持Tomcat 8(以及Tomcat 7、Jetty 7/8/9)和SpringBoot开箱即用。不需要依赖项调整


披露:我是Gretty插件的作者。

用于设置我使用的tomcat版本:

    dependencies {
    compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}") {
        exclude module: "spring-boot-starter-tomcat"
    }
    compile 'org.springframework.boot:spring-boot-starter-tomcat:1.1.8.RELEASE'
}

您只需要找到哪个spring boot starter tomcat适合您的需要

这就是我如何配置spring Boot1.3.3以与tomcat v8.0.33配合使用的方法。默认情况下,它适用于8.0.32版本,并且该版本存在Websocket问题

  compile("org.springframework.boot:spring-boot-starter-web") {
    exclude module: "spring-boot-starter-tomcat"
  }
  //providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
  compile 'org.apache.tomcat.embed:tomcat-embed-core:8.0.33'
  compile 'org.apache.tomcat.embed:tomcat-embed-el:8.0.33'
  compile 'org.apache.tomcat.embed:tomcat-embed-logging-juli:8.0.33'
  compile 'org.apache.tomcat.embed:tomcat-embed-websocket:8.0.33'

Spring Boot 1.2默认使用tomcat 8。
  compile("org.springframework.boot:spring-boot-starter-web") {
    exclude module: "spring-boot-starter-tomcat"
  }
  //providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
  compile 'org.apache.tomcat.embed:tomcat-embed-core:8.0.33'
  compile 'org.apache.tomcat.embed:tomcat-embed-el:8.0.33'
  compile 'org.apache.tomcat.embed:tomcat-embed-logging-juli:8.0.33'
  compile 'org.apache.tomcat.embed:tomcat-embed-websocket:8.0.33'