Gradle版本:5.6.3
引入插件版本:gradle-tomcat-plugin:2.2.5
buildscript { repositories { jcenter() } dependencies { classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.5' } } plugins { id 'java' id 'war' } apply plugin: 'com.bmuschko.tomcat' //tomcat: 插件 group 'org.springframework' version '5.1.12.BUILD-SNAPSHOT' sourceCompatibility = 1.8 repositories { mavenCentral() } dependencies { compile(project(":spring-webmvc")) testCompile group: 'junit', name: 'junit', version: '4.11' testCompile group: 'junit', name: 'junit', version: '4.12' def tomcatVersion = '8.0.42' tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}", "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}", "org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}" } tomcat { httpProtocol = 'org.apache.coyote.http11.Http11Nio2Protocol' ajpProtocol = 'org.apache.coyote.ajp.AjpNio2Protocol' } // UTF-8 tasks.withType(JavaCompile) { options.encoding = "UTF-8" }
配置后在gradle对应的项目下,会在Tasks下将新增 Web Application
执行 tomcatRunWar