2014-03-24 123 views
7

春季啓動參考指南提供了一種通過在Maven中設置的自定義屬性升級到Tomcat 8條指令:春季啓動Tomcat的搖籃8

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

什麼是等價的方式做同樣的搖籃建?

我試過以下無濟於事。它在應用程序啓動時保持在7.0.52版本中。

buildscript { 
    ...  
    ext['tomcat.version'] = '8.0.3' 
    ... 
} 
+0

Spring Boot 1.2將默認使用tomcat 8。 https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.2-Release-Notes#servlet-31-tomcat-8-and-jetty-9 – TheKojuEffect

回答

3

Gradle沒有等價的「父pom」,所以你必須顯式地調用依賴。因爲它是時髦,你也許可以做到這一點編程,像:

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

我們可以添加對版本屬性春節引導搖籃插件(隨意打開在github上一個問題)的一些支持,但它可能會必須是可選的。

3

請看Gretty插件:它支持Tomcat 8(以及Tomcat 7,Jetty 7/8/9)和SpringBoot開箱即用。不需要依賴性調整。

https://github.com/akhikhl/gretty

披露:我Gretty插件的作者。

0

有關設置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' 
} 

,你只需要找到該彈簧引導起動tomcat的滿足您的需求

0

這是我怎麼可能配置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'