Setting a Tomcat version with Spring Boot and Gradle

Spring Boot allows you to easily specify a tomcat version when using Maven (Docs). But there doesn’t seem to be an equivalent mechanism for Gradle.

To lock down a specific tomcat version for war deployment, I found that I had to exclude the starter-tomcat module and add the dependencies specified in the tomcat starter POM in my Spring Boot project’s build.gradle file.

compile('org.springframework.boot:spring-boot-starter-web:1.0.0.RC4'){
   exclude module: spring-boot-starter-tomcat
}
providedRuntime 'org.apache.tomcat.embed:tomcat-embed-core:7.0.52'
providedRuntime 'org.apache.tomcat.embed:tomcat-embed-el:7.0.52'
providedRuntime 'org.apache.tomcat.embed:tomcat-embed-logging-juli:7.0.52'
providedRuntime 'org.apache.tomcat:tomcat7-websocket:7.0.52'

Note: embed-el doesn’t seem to be included in versions below 7.0.52.

I imagine a similar approach would be needed to use Jetty 9.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s